Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up
Problem Submissions Solution

Root To Leaf Path Sum

Difficulty: Medium

Acceptance: 78.56%

Points: 30.00

You are given the root of a **binary tree** and an integer **targetSum**. Your task is to determine whether there exists a **root-to-leaf path** such that the sum of the node values along the path equals **targetSum**. A **root-to-leaf path** is a path that: - Starts from the **root node**. - Ends at a **leaf node** (a node with no children). - Includes every node along the path exactly once. Return **`true`** if such a path exists; otherwise, return **`false`**.

Topics

Companies

Articles

Examples:
Constraints:
  • - **0 = Number of nodes = 105**
  • - **-10? = Node.data = 10?**
  • - **-10? = targetSum = 10?**
Companies:
Samsung Sprinklr Myntra
Topics:
Tree Traversal Binary Tree
Locked Content
Access Restricted: Please Login to access the code editor and test cases.