salt_n_ice's blog

By salt_n_ice, history, 6 years ago, In English

Problem Link

Here is my implementation: * Here, sn and en stands for starting node and ending node respectively, and mini_map is the 2d array showing path of shortest distance from starting node to all other reachable nodes. Rest is Breadth-First Search.

I don't see whats making this solution so long

Code
  • Vote: I like it
  • -18
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

Whenever ask doubt about a problem:

  1. Place your code in spoiler
  2. Insert link to the problem in blog

res = x+res;

this statement works in linear time( every time you insert a new character in front of string all characters of string are shifted one step right)

so insert at back and then reverse the string at the end