Блог пользователя avdp

Автор avdp, история, 6 лет назад, По-английски

1020B - Badge

Guys can Someone give me O(N) approach for this problem as When I checked around 20-30 solutions all were O(N^2) so I need a code basically as I have some idea that If a node is in cycle then the answer is the node itself and else the answer is nearest node in a cycle.

Please help me implement code for O(N).

P.S. I checked that no blog exists on this problem and Please forgive me as I know this may be a NOOB doubt and I have started learning Graphs a week back only.

  • Проголосовать: нравится
  • -13
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

why not write a O(N^2) solution, or read the editorial?