Skip to content

Add unit tests for the "Subtree of Another Tree" problem. - #40

Merged
kobukuro merged 3 commits into
mainfrom
test/add-subtree-of-another-tree-tests
Jan 25, 2026
Merged

kobukuro merged 3 commits into
mainfrom
test/add-subtree-of-another-tree-tests

Conversation

@kobukuro

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 25, 2026 02:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a proper packaged implementation and unit tests for the LeetCode “Subtree of Another Tree” (572) problem, aligning it with the existing com.leetcode.easy structure.

Changes:

  • Introduced SubtreeOfAnotherTree572 under src/main/java/com/leetcode/easy/ using com.leetcode.datastructure.TreeNode and added detailed time/space complexity documentation.
  • Added SubtreeOfAnotherTree572Test under src/test/java/com/leetcode/easy/ with JUnit 5 tests that cover the main LeetCode examples.
  • Removed the old default‑package src/SubtreeOfAnotherTree572.java implementation and its demo main method in favor of the new structured layout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/main/java/com/leetcode/easy/SubtreeOfAnotherTree572.java New packaged implementation of the subtree check with helper isSameTree and documented complexity.
src/test/java/com/leetcode/easy/SubtreeOfAnotherTree572Test.java New JUnit test class validating isSubtree against the two standard example cases.
src/SubtreeOfAnotherTree572.java Legacy default‑package implementation and demo main removed now that a structured class and tests exist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/leetcode/easy/SubtreeOfAnotherTree572.java Outdated
Comment thread src/main/java/com/leetcode/easy/SubtreeOfAnotherTree572.java Outdated
Comment on lines +43 to +47
if (subRoot == null) {
return true;
}
if (root == null) {
return false;

Copilot AI Jan 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branches handling subRoot == null and root == null are not covered by the new tests; consider adding unit tests in SubtreeOfAnotherTree572Test for cases like (root = null, subRoot != null) and (root != null, subRoot = null) to exercise these code paths and guard their behavior.

Copilot uses AI. Check for mistakes.
@kobukuro
kobukuro merged commit 05f5eb9 into main Jan 25, 2026
1 check passed
@kobukuro
kobukuro deleted the test/add-subtree-of-another-tree-tests branch January 25, 2026 02:36
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