yingzhong.xu
BAN USER
Comments (4)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
A* algorithm should solve this problem because we know the coordinates, use a priorityQueue to store unvisited nodes(expanded from current node)
- yingzhong.xu October 27, 2013Comment hidden because of low score. Click to expand.
0
of 0 vote
I think this solution works!
- yingzhong.xu September 06, 2013Comment hidden because of low score. Click to expand.
0
of 0 vote
Same as I thought, actually it can be optimized,
the current_index can jump directly to the next_negative_index previously found.
For example:
[ -1, <1>, 2, 3, 4, -2, -3, ..]
suppose after first iteration, we get:
[ -1, -2 , 1, 2, 3, 4, -3 ..]
then we can let current_index jump to <4> (the position of -2 before swap) directly instead of starting from <1> , and then repeat the iteration.
This is O(n) regardless of the swapping part...
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Can we use a trie tree to store the # of people visited based on the country/state/city name (suppose their names are unique)
- yingzhong.xu October 27, 2013