My HRT interview had the same question as this other post (the link I'm referring to is dropped here).
Their bar is really high. In half an hour you need to understand the problem, explain the problem, explain your approach, write the code, explain the code, and run it.
I went straight to the optimized solution: record the capacity in each of the four directions (up, down, left, right) for every point, then use the difference between the timestamps of the actions to directly compute how far you can get in the current direction. It was bug free and I got it in one pass.
But I misunderstood one setting of the problem: whether the points in the graph are actually walkable. I assumed they were walkable, so by my understanding the code was completely correct. After I finished writing it, the interviewer told me that the points are not walkable. I then asked how I should change the code, but there was no time left to actually finish the change.
I still didn't pass. Maybe they put a lot of weight on understanding the problem, so confirming the details of the problem first really matters. In that amount of time there is basically no room to debug at all, they want it written correctly in one pass.
Discussion
Loading comments…