title: Converging maze: Largest cycle
body: <p>This question was asked in one interview and i am still hunting for the best solution.</p>
  
  <p>You are given a maze with N cells. Each cell may have multiple entry points but not more than one exit
  (ie. entry/exit points are unidirectional doors like valves). </p>
  
  <p>The cells are named with an integer value from 0
  to N-1.</p>
  
  <p>You need to find the the length of the largest cycle in the maze. Return -1 if there are no cycles.</p>
  
  <p>INPUT FORMAT</p>
  
  <ul>
  <li>First line has the number of cells N</li>
  <li>Second line has list of N values of the edge[] array. edge[i] contains the cell number that
  can be reached from of cell ‘i’ in one step. edge[i] is -1 if the ‘i’th cell doesn’t have an exit.</li>
  </ul>
  
  <p>OUTPUT FORMAT</p>
  
  <ul>
  <li>length of the largest cycle.</li>
  </ul>
  
  <p>Sample input: </p>
  
  <p>23</p>
  
  <p>4 4 1 4 13 8 8 8 0 8 14 9 15 11 -1 10 15 22 22 22 22 22 21</p>
  
  <p>Sample output</p>
  
  <p>6</p>
  
  <p>I have already tried to do this with DFS to find all possible cycles and print the largest cycle size.
  Please let me know if there is any better solution for the same.</p>