Skip to content

Complete Trees-1#1729

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

Complete Trees-1#1729
PrakarshKamal wants to merge 1 commit intosuper30admin:masterfrom
PrakarshKamal:master

Conversation

@PrakarshKamal
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Strengths:

  • The solution correctly implements the recursive range-checking method for validating BST.
  • It handles edge cases with integer boundaries by using long min and max.
  • The code is clean and easy to understand.

Areas for Improvement:

  • The TreeNode class should not be redefined in the same file. The problem already provides the definition, so including it again may cause duplication. Remove the TreeNode class from ValidateBST.java.
  • Although the solution is correct, note that the space complexity is O(h) due to recursion, which is efficient. However, in the worst case (skewed tree), h could be n, leading to O(n) space. This is acceptable and matches the reference solution.
  • The solution for a different problem (ConstructBTFromPreAndIn) is included in the same submission. Make sure to only submit the code for the problem being solved.

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