摘要: [抄题]: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume th 阅读全文
posted @ 2018-03-14 22:46 苗妙苗 阅读(166) 评论(0) 推荐(0)
摘要: [抄题]: Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any 阅读全文
posted @ 2018-03-14 21:58 苗妙苗 阅读(161) 评论(0) 推荐(0)
摘要: [抄题]: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path 阅读全文
posted @ 2018-03-14 20:43 苗妙苗 阅读(186) 评论(0) 推荐(0)
摘要: [抄题]: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You 阅读全文
posted @ 2018-03-14 18:28 苗妙苗 阅读(291) 评论(0) 推荐(0)
摘要: [抄题]: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others 阅读全文
posted @ 2018-03-14 12:03 苗妙苗 阅读(239) 评论(0) 推荐(0)
摘要: [抄题]: Invert a binary tree. to [暴力解法]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 以为要分为r.r = l.l, r.l = l.r来讨论,但是其实这样只能最后判断相等。翻转是每一步都要进行的动作,应该尽早开始 阅读全文
posted @ 2018-03-14 11:29 苗妙苗 阅读(134) 评论(0) 推荐(0)
摘要: [抄题]: Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: [暴力解法]: 时间分析 阅读全文
posted @ 2018-03-14 10:06 苗妙苗 阅读(201) 评论(0) 推荐(0)