salt_n_ice's blog

By salt_n_ice, history, 3 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?
»
3 years ago, # |
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

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Okay, I will edit the question. And I did 'res = res + x' and still, it's giving me TLE for that case.