{"id":22513619,"url":"https://github.com/emahtab/path-sum","last_synced_at":"2026-02-18T00:01:37.855Z","repository":{"id":79525707,"uuid":"398434697","full_name":"eMahtab/path-sum","owner":"eMahtab","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-21T01:04:06.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T21:41:42.426Z","etag":null,"topics":["dfs","leetcode","tree"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-08-21T00:59:11.000Z","updated_at":"2021-08-21T02:09:10.000Z","dependencies_parsed_at":"2023-05-10T17:30:32.091Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/path-sum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eMahtab/path-sum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpath-sum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpath-sum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpath-sum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpath-sum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/path-sum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpath-sum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29563273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dfs","leetcode","tree"],"created_at":"2024-12-07T03:13:44.056Z","updated_at":"2026-02-18T00:01:37.838Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Path Sum \n\n## https://leetcode.com/problems/path-sum\n\nGiven the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.\n\nA leaf is a node with no children.\n\n![Path Sum example](pathsum.jpg?raw=true \"Root to Leaf Path Sum\")\n\n\n# Implementation : DFS\n```java\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n    public boolean hasPathSum(TreeNode root, int targetSum) {\n        if(root == null)\n            return false;\n        return traverse(root, targetSum);\n    }\n    \n    private boolean traverse(TreeNode node, int targetSum) {\n        if(node.left == null \u0026\u0026 node.right == null \u0026\u0026 node.val == targetSum)\n            return true;\n        boolean leftPath = false;\n        if(node.left != null)\n            leftPath = traverse(node.left, targetSum - node.val);\n        boolean rightPath = false;\n        if(node.right != null)\n            rightPath = traverse(node.right, targetSum - node.val);\n        \n        return leftPath || rightPath;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fpath-sum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fpath-sum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fpath-sum/lists"}