logo

Given an integer targetSum and a binary tree representing a root-to-leaf path that adds up all the values along the path, return true if and only if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.

Given an integer targetSum and a binary tree representing a root-to-leaf path that adds up all the values along the path, return true if and only if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.

题目类型: 技术面试题

这是一道技术面试题,常见于澳洲IT公司面试中。

难度: easy

标签: interviewbit, qualcomm, company-specific

目标公司: Qualcomm

参考答案摘要

Example 1: Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 Output: true Explanation: The root-to-leaf path with the target sum is shown. Example 2: Input: root = [1,2,3], targe...

本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。

← 返回面试题库

Given an integer targetSum and a binary tree representing a root-to-leaf path that adds up all the values along the path, return true if and only if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.

Easy

想查看完整答案?

登录匠人学院学习中心,获取 STAR 格式回答和详细技术解析

前往学习中心查看答案