What is the space complexity for DFS approach?
Posts made by palindrome88
Write function to determine when a driver can drive?Drivers are not allowed to drive a total of 14 hours without an 8 hour break.
Input: shifts(shiftStart, shiftEnd), current time(can be > 24)
[(0, 11), (12, 19)], 24
For the above example the function should return true
[(0, 3), (4, 8), (9, 13), (14, 18), (19, 23)], 24
For the above example, the function should return false. (3-0)+(8-4)+4+4 > 12, driver has to take a break, so function has to return false.
RE: Guess 4-digit random number with a testing function
@awice Hey, do you have sample code?
String pyramid transition matrix
I was asked the below question in my Google phone interview.
Problem: given a list of leaf nodes in a pyramid ，and a map which indicates what's the possible parent node given a left and right node. Return true if the one of leaf node could turn into the root node, Otherwise, return false.
Example: root / \ X X /\ /\ X X X / \/ \/ \ A B C D Map: left: A | B | C | D right --------------------------------- A B | A or C | D | A B D |B or C | A | C B D
Note:1. If left child is B, right child is A, the parent node could be B or C