摘要: 470. Tweaked Identical Binary Tree Check two given binary trees are identical or not. Assuming any number of tweaksare allowed. A tweak is defined as 阅读全文
posted @ 2019-04-09 11:05 IreneZh 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 2. Min Stack Implement a stack with following functions: push(val) push val into the stack pop() pop the top element and return it min() return the sm 阅读全文
posted @ 2019-04-07 19:26 IreneZh 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 思路: 数据结构:stack。遍历整个字符串,如果遇到左向括号( [ { 则入栈。如果遇到右向括号时,先检查栈是否为空,为空说明左右向括号数目不一致,返回false;不为空则弹出栈顶元素查看是否和右向括号匹配。遍历完,要return stack.isEmpty(); 确保栈内没有剩余。 代码: 代码 阅读全文
posted @ 2019-04-07 13:44 IreneZh 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 97. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the 阅读全文
posted @ 2019-04-06 16:12 IreneZh 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 175. Invert Binary Tree Invert a binary tree. Example Example 1: Input: {1,3,#} Output: {1,#,3} Explanation: 1 1 / => \ 3 3 Example 2: Input: {1,2,3,# 阅读全文
posted @ 2019-04-06 15:14 IreneZh 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 469. Same Tree Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has 阅读全文
posted @ 2019-04-06 14:42 IreneZh 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 480. Binary Tree Paths Given a binary tree, return all root-to-leaf paths. Given a binary tree, return all root-to-leaf paths. Given a binary tree, re 阅读全文
posted @ 2019-04-06 14:27 IreneZh 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 481. Binary Tree Leaf Sum Given a binary tree, calculate the sum of leaves. Given a binary tree, calculate the sum of leaves. Given a binary tree, cal 阅读全文
posted @ 2019-04-06 13:08 IreneZh 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 482. Binary Tree Level Sum Given a binary tree and an integer which is the depth of the target level. Calculate the sum of the nodes in the target lev 阅读全文
posted @ 2019-04-06 12:54 IreneZh 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 376. Binary Tree Path Sum Given a binary tree, find all paths that sum of the nodes in the path equals to a given number target. A valid path is from 阅读全文
posted @ 2019-04-04 19:41 IreneZh 阅读(186) 评论(0) 推荐(0) 编辑