Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Binary Tree Path Sum (easy)

Problem Statement

Given a binary tree and a number ‘S’, find if the tree has a path from root-to-leaf such that the sum of all the node values of that path equals ‘S’.


  • The number of nodes in the tree is in the range [0, 5000].
  • -1000 <= Node.val <= 1000
  • -1000 <= targetSum <= 1000

Try it yourself

Try solving this question here:




Like the course? Get enrolled and start learning!