Repository navigation
Add solution for "Path Sum" with unit tests. - #33
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a solution for LeetCode problem #112 (Path Sum), implementing a depth-first search algorithm to determine whether a binary tree has a root-to-leaf path with a given sum.
Key changes:
- Implements recursive DFS solution with O(N) time and O(N) space complexity
- Adds comprehensive test coverage with three test cases covering positive, negative, and edge cases
- Includes detailed complexity analysis in documentation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/main/java/com/leetcode/easy/PathSum112.java |
Implements the hasPathSum method using recursive DFS to check for root-to-leaf paths matching the target sum |
src/test/java/com/leetcode/easy/PathSum112Test.java |
Adds unit tests covering a tree with valid path, a tree without valid path, and null tree edge case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.