mohit_joshi's blog

By mohit_joshi, history, 6 months ago, In English

Problem link I have applied the same approach as mentioned in the editorial , but I am still getting TLE.I need some hints about where I am doing wrong. Mycodelink Thanks for the help in advance.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Constant factors matter. While your solution technically has the correct time complexity, there's no need to use maps in your data struct, you could use arrays of size 3 instead, which speeds up your solution considerably.

  • »
    »
    6 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes it worked! Learnt a lesson , sometimes constant factor matters:D Thanks