Skip to content

Tag: algorithm

Separate date to several intervals

I’ve got an array like the following : And another array : I would like to create a new $array3 that removes the intervals from $array2 in $array1 to give the following result : As you can see, in $array3 2 new entries were added to remove the interval used in $array2. I don’t know how can I tackl…

PHP topological sort

LIST: controller name => priority:required controllers sorted and expected output: First sort by priority, then reorder based on required controllers to be loaded before. ensure not to be stuck in an infinite loop due to controllers requiring each other. I assume I’ll need something like this: Please…

Get dependencies Ids Algorithm

I have this problem and I came out with a solution but what is the best way to solve this problem ? Thank you in advance. Given an array of strings and an array of tasks you need to return a sorted array with tasks and dependencies tasks ids. Example: Expected output: So far this is the solution I built,

Create Array From Key

Thank you in advance. Is there any way to create a multidimensional array from key names. Transform to this array. Thank you ! Answer Try my code (I used the reference operator “&” to get the successive inner arrays): Input array: php code: Result array: