Round 1
Questions:
-
Given a log file of inputs with functions and timestamp:
foo 0 bar 10 bar 30 foobar 50 foobar 70 foo 100
return the time per each function minus the internal calls. Expected output:
{ bar: 20, foobar: 20, foo: 60 }
-
Given a MxN matrix, starting from top left, return the most optimal path from top left to bottom right. Return an invalid case if cannot get out. (Similar to 1091. Shortest Path in Binary Matrix but expecting path and only 4 directions)
- Example:
[ 0 0 0 1 0 1 1 0 0 ] -> [[0,0], [0,1], [1,1], [2,1], [2,2]] [ 0 0 0 1 1 1 1 0 0 ] -> [-1]
- Follow-up: Since BFS is O(M^2N^2) space complexity, can you do better?
- Example:
Candidate's Approach
My attempt: Solved problem 1 with ease, stuck on problem 2 with improving space complexity after using BFS on a queue storing the path to each space for each node.
Interviewer's Feedback
No feedback provided.