dharm0us's blog

By dharm0us, 9 years ago, In English

My solution code is along the following lines but it fails on test 4 for wrong answer. Can someone explain what's wrong with this logic/code?

  1. Create a Directed Acyclic Graph by creating edges from a vertex to all the next possible vertices (based on the previous jump length).

  2. Now find the vertex with maximum distance from source vertex. Since it's a DAG, do topological sort and find the longest path in a DAG. Here weight(u,v) is number of gems on vertex v(island v).

Here is my code.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it