Condition #3 seems to be redundant. If every node (excluding the root) has exactly 1 parent and there is exactly 1 root, then a cycle cannot exist because by definition a cycle contains 1 point with 2 parents.
@shiv-yt-317Ай бұрын
This was beautiful! Proving your algo works with test cases is just the best thing any dev can and should do.
@rishiraj2548Ай бұрын
Thanks
@zwischenzug910Ай бұрын
this felt like a manager teaching its subordinate, lmao!