shyam81295's blog

By shyam81295, history, 6 years ago, In English

I have implemented sliding window method in this problem, but there's TLE for testcase 9 . This is the link. I know the solution is wrong, but I want to know where I am going wrong, so that I shouldn't repeat same mistake again. It would be nice if someone of you will guide me to resolve this issue. Thanking in advance.

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

»
6 years ago, # |
  Vote: I like it +2 Vote: I do not like it

It's clear that, your solution has a complexity of O(n^2). Which is not enough to pass the test cases. This problem is very easy to solve using two pointer algorithm. I'm not sure if you are familiar with this algorithm or not. May be you have implemented this algorithm in a wrong way. Try 16375131.

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

Hello Shyam,

I think you re facing pretty problems in basics.When you have any doubt on any problem just post a blog on it and ping me though codeforces talks.I will help you with that.Thanks.Happy coding.
  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks mate, I would surely get help from you. I hope it will improve my programming skills faster than practicing alone.