1372

leetcode1372dp求交错路径长

bfd+dp unordered_map<TreeNode* ,int>d,p; queue<pair<TreeNode* ,TreeNode*>>q; int dp(TreeNode* root){ d[root]=p[root]=0; q.push({root,nullptr}); while( ......
路径 leetcode 1372 dp

力扣---1372. 二叉树中的最长交错路径

给你一棵以 root 为根的二叉树,二叉树中的交错路径定义如下: 选择二叉树中 任意 节点和一个方向(左或者右)。如果前进方向为右,那么移动到当前节点的的右子节点,否则移动到它的左子节点。改变前进方向:左变右或者右变左。重复第二步和第三步,直到你在树中无法继续移动。交错路径的长度定义为:访问过的节点 ......
路径 1372

[LeetCode] 1372. Longest ZigZag Path in a Binary Tree

You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (rig ......
LeetCode Longest Binary ZigZag 1372
共3篇  :1/1页 首页上一页1下一页尾页