Please read the new rule regarding the restriction on the use of AI tools. ×

avdp's blog

By avdp, history, 4 years ago, In English

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.

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

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

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