title: can it be solved in linear time, did this in n^2 time
body: <p>the problem goes like this</p>
  
  <p>suggest a data structure and write a program to count the number of employees referred by an employee(directly or indirectly) in linear time. for example</p>
  
  <pre><code>  A B C D E F G 
  A 0 1 0 0 0 0 0 A referred 4 (A referred B, B referred C and D and D referred E)
  B 0 0 1 1 0 0 0 B referred 3 
  C 0 0 0 0 0 0 0
  D 0 0 0 0 1 0 0 D referred 1
  E 0 0 0 0 0 0 0
  F 0 0 0 0 0 0 1 F referred 1
  G 0 0 0 0 0 0 0 
  </code></pre>
  
  <p>did this using a two dimensional array, can it be done in linear time?</p>
  
  <p>Note that an employee can obviously not be recommended by someone he directly or indirectly recommended, so there will be no cycles in the graph.  A new employee can be recommended by only one employee. while each employee can recommend multiple employees.</p>