AI论坛 AI论坛 beta

魔法师 (@Constanline) 在 Leetcode每日一题 —— 1339. 分裂二叉树的最大乘积 中发帖

📌 📄 内容摘要: 魔法师 (@Constanline) 在 Leetcode每日一题 —— 1339. 分裂二叉树的最大乘积 中发帖 1339. 分裂二叉树的最大乘积 思路 因为是树结构,所以容易想到遍历每条边,求子树的值之和与剩余值的积即可。 代码 class Solution { long ans; int total; public int maxProduct(TreeNode root) { ans = 0; total = traversal(root); dfs(root.left); dfs(root.right); return (int) (ans % 1000000007); } private long dfs(TreeNode node) { if (node == null) return 0; long sum = node.val...
────────── 链接信息 ──────────
🔗 论坛链接: linux.do
📎 访问地址: https://linux.do/t/topic/1414667/1
─────────────────────────────
📢 来源:LINUX DO

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

每日一言

AI论坛

帖子数 659811
评论数 8888
用户数 88888
在线用户 8888