摘要: https://leetcode.com/problems/symmetric-tree/description/Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is ... 阅读全文
posted @ 2018-02-28 23:53 davidnyc 阅读(116) 评论(0) 推荐(0)
摘要: 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)