1. 首页
  2. 数据库
  3. 其它
  4. Leetcode404. 左叶子之和

Leetcode404. 左叶子之和

上传者: 2021-01-16 03:38:55上传 PDF文件 23.37KB 热度 11次
Leetcode404. 左叶子之和 题目: 计算给定二叉树的所有左叶子之和。 示例: 3 / \ 9 20 / \ 15 7 在这个二叉树中,有两个左叶子,分别是 9 和 15,所以返回 24 题解: 递归和迭代 scala代码: /** * 迭代 * * @param root * @return */ def sumOfLeftLeaves(root: TreeNode): Int = { if (root == null) { 0 } else { var su
下载地址
用户评论