Wayve Interview Question

Time complexity of solution Space complexity of solution