reaper28's blog

By reaper28, history, 4 years ago, In English

question : https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ff43/00000000003379bb solution : https://ideone.com/u8gzBD Why is it giving WA please help anyone... I have maintained which character comes under which in an array neeche[26] . i have made the graph using that array and done bfs for output.

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

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

According to me your initial idea is perfectly fine, I mean the approach while creating the array. But there may be many indirect connections too, which can make an element dependent of an other element which it is not directly connected. I don't think your code handles that portion(I may be wrong). You can check all the dependencies by simply performing topological sort using Kahn's Algorithm by creating a directed graph based upon the dependencies. Here's my code if you want to take a look : https://ideone.com/TUerfZ