Skip to content

Completed Trees-1#1713

Open
Nikesh46 wants to merge 1 commit intosuper30admin:masterfrom
Nikesh46:master
Open

Completed Trees-1#1713
Nikesh46 wants to merge 1 commit intosuper30admin:masterfrom
Nikesh46:master

Conversation

@Nikesh46
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Strengths:

  • The code is well-commented and follows a clear structure.
  • The use of a global prev node and breach flag is a good approach, similar to the reference solution.
  • The time and space complexity are correctly identified and match the optimal solution.

Areas for Improvement:

  • The redundant check in the right subtree traversal (if (prev != null && node.val > prev.val)) should be removed as it disrupts the in-order traversal logic and causes incorrect results.
  • The breach flag should be checked only once during the in-order traversal, specifically when comparing the current node's value with the previous node's value.
  • The solution should ensure that the in-order traversal maintains the BST property correctly without additional checks that could interfere with the logic.

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