Skip to content

Add solution for "Path Sum" with unit tests. - #33

Merged
kobukuro merged 1 commit into
mainfrom
feat/path-sum
Nov 8, 2025
Merged

kobukuro merged 1 commit into
mainfrom
feat/path-sum

Conversation

@kobukuro

@kobukuro kobukuro commented Nov 8, 2025

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings November 8, 2025 04:12

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 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.

@kobukuro
kobukuro merged commit a92c04b into main Nov 8, 2025
7 checks passed
@kobukuro
kobukuro deleted the feat/path-sum branch November 8, 2025 04:15
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