Skip to content

Conversation

@PrasiddhShah
Copy link

No description provided.

@super30admin
Copy link
Owner

  • Problem1.java: Well done! Your BFS implementation is correct and efficient. The comments are clear and helpful.
  • Problem2.java: Your approach is on the right track but needs improvement. The main issue is that you're not correctly checking if x and y have the same parent. You should track both depth and parent information to accurately determine if nodes are cousins. Also, the space complexity should be O(h) due to recursion stack, not O(1). Consider modifying your DFS to track parent nodes as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants