WorldWarIV's blog

By WorldWarIV, history, 8 years ago, In English

Had it been given that the sequence of integers p1,p2..pn is not necessarily a permutation, it would have been a more interesting problem ! How will we solve this modified version of the problem?

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

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

Maybe you find amount of strongly connected components ?

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

I didn't read the statement carefully and thought this was the condition and tried to solve the harder problem, but failed due to missing a case. :(

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

I guess just one extra change has to be made if components = 1 and graph is not cycle then ans++