We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'm pretty sure that this question needs to test edge cases better; I came up with a completely naive algorithm that shouldn't work for low k or a disconnected city, but it passed all tests.
The problem states "Every timestep, each zombie RANDOMLY chooses one of its neighboring junctions and walks towards it.", so, how can the solution be always the same?
I tested by downloading a failed input and the test case failed saying "Terminated due to timeout" even before completing the task of forming a graph for me to perform manipulations on it ! Any suggestions ?
Can we asume zombies can (when they have enough time) traverse the entire city? In other words is the graph representing the city always connected, or can it consist of mutiple components?
No more comments
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
I'm pretty sure that this question needs to test edge cases better; I came up with a completely naive algorithm that shouldn't work for low k or a disconnected city, but it passed all tests.
The problem states "Every timestep, each zombie RANDOMLY chooses one of its neighboring junctions and walks towards it.", so, how can the solution be always the same?
I can't seem to get my code to run under 2 seconds. Got the right output otherwise. This loop is what's costing me most:
Any idea on how I could speed this up ?
I tested by downloading a failed input and the test case failed saying "Terminated due to timeout" even before completing the task of forming a graph for me to perform manipulations on it ! Any suggestions ?
Can we asume zombies can (when they have enough time) traverse the entire city? In other words is the graph representing the city always connected, or can it consist of mutiple components?