mauliksoneji's blog

By mauliksoneji, 9 years ago, In English

Hi everyone, I was attempting the following question: http://www.spoj.com/problems/FREQUENT/

I tried to use Segment trees for this question but I am getting WA. Please help me get an idea about where I am wrong. Here is the link to the code: http://ideone.com/leiE86

Thanking you, Maulik

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

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

What about your search , when you found a empty segment (Line 82) you are puting many flag values this strategy is correct , but you are forgeting what to do when in (Line 82) when your get recursively from LEFT and RIGHT , and imagine that LEFT is an invalid segment (in this case i think that you are not considering this case) the same when RIGHT is an empty segment.