上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: https://leetcode.com/problems/same-tree/description/Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally iden... 阅读全文
posted @ 2018-02-28 23:19 davidnyc 阅读(152) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/count-univalue-subtrees/description/Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For... 阅读全文
posted @ 2018-02-28 11:11 davidnyc 阅读(110) 评论(0) 推荐(0)
摘要: 网上还有一种做法用STACK 现在无法理解,以后再弄! 阅读全文
posted @ 2018-02-28 05:50 davidnyc 阅读(134) 评论(0) 推荐(0)
摘要: given an array, and an element to insert, and the position to insert this element,return a new array with the element inserted1,2,3,4,5,6 -> 1,2,3,15,4,5,6 1 public static void main(String[] args) {... 阅读全文
posted @ 2018-02-28 03:20 davidnyc 阅读(201) 评论(0) 推荐(0)
摘要: 用一次遍历,一个指针完成 2,3,8,4,1 -> 1,4,8,3,2 1 public static void main(String[] args) { 2 int[] org = {2,3,8,4,1 } ; 3 int[] res = reverseArray(org); 4 print(res); 5 } 6 7 ... 阅读全文
posted @ 2018-02-28 02:22 davidnyc 阅读(170) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/invert-binary-tree/description/Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1time: o(n) : n nodes space:... 阅读全文
posted @ 2018-02-27 23:41 davidnyc 阅读(105) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/binary-tree-inorder-traversal/description/ Given a binary tree, return the inorder traversal of its nodes' values. For e 阅读全文
posted @ 2018-02-27 09:32 davidnyc 阅读(117) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/binary-tree-preorder-traversal/description/ Given a binary tree, return the preorder traversal of its nodes' values. For 阅读全文
posted @ 2018-02-27 09:29 davidnyc 阅读(114) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/maximum-depth-of-binary-tree/description/Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node do... 阅读全文
posted @ 2018-02-27 02:58 davidnyc 阅读(112) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/balanced-binary-tree/description/Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in wh... 阅读全文
posted @ 2018-02-27 02:39 davidnyc 阅读(136) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页