How to solve this graph problem in O(N^2) ?

Revision en1, by drexdelta, 2024-12-09 16:47:07

Hi all, I have just now solved this leetcode problem in O(N^3).

I am curious if we can solve this problem in O ( N ^ 2 ) ?

For those, who are interested in understanding O ( N ^ 3 ) approach, please let me know, I will try my best to explain.

MY code for O ( N ^ 3 )
Tags graphs, optimisation

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English drexdelta 2024-12-09 16:47:07 2901 Initial revision (published)