摘要:
我的方法:注意最方便的获取一个数每一位的方法,是把它转化为String先,通过String.valueOf(int c) O(1): http://my.oschina.net/Tsybius2014/blog/497645 另一个方法比较简单,可以举例说明一下。假设输入的数字是一个5位数字num, 阅读全文
摘要:
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->... 阅读全文
摘要:
4 / \ 2 6 / \ / \ 1 3 5 7 如图所示BST, preorder结果是 4 2 1 3 6 5 7 4是root, 213是左子树,657是右子树 idea就是右子树不能再出现比root小的数,一旦出现,return false. 这样一层一层recursion, 直到子树只剩 阅读全文
摘要:
Like the previous one Meeting Room, still need to sort the intervals using a comparator. We need to simulate the process to know the maximum number of 阅读全文
摘要:
Interval as an array: Previous interval as an object: Implement a Comparator<Interval> Syntax: don't forget the public sign when defining a function 阅读全文
摘要:
Implement an iterator to flatten a 2d vector.For example,Given 2d vector =[ [1,2], [3], [4,5,6]]By calling next repeatedly until hasNext returns fa... 阅读全文
摘要:
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 example:Given b... 阅读全文
摘要:
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequen... 阅读全文