摘要:
就是一棵任意形状的树,给你一个数k,让你把这棵数变成每个节点只有k或者0个孩子的结构,之前某节点孩子不可以变成该节点的祖先,但是可以是兄弟由于第一题扣细节逻辑花了40分钟(主要是我一开始没有理解面试官的困惑,然后一步一步的解释来着),第二题就说了个思路(我的想法就是层序遍历然后把对应是一层的节点放到 阅读全文
摘要:
Solution 1: Reservior sampling: (wiki introduction) Reservoir sampling is a family of randomized algorithms for randomly choosing a sample of k items 阅读全文
摘要:
Strobogrammatic Number II give us all the strings with length n, then we can call it to get strings with length between low.length() and high.length() 阅读全文
摘要:
参考http://segmentfault.com/a/1190000003787462 找出所有的可能,必然是深度优先搜索。但是每轮搜索如何建立临时的字符串呢?因为数是“对称”的,我们插入一个字母就知道对应位置的另一个字母是什么,所以我们可以从中间插入来建立这个临时的字符串。这样每次从中间插入两个 阅读全文
摘要:
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as ... 阅读全文
摘要:
Since n may be a large number compared to the length of list. So we need to know the length of linked list.After that, move the list after the (l-n%l 阅读全文
摘要:
Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For 阅读全文
摘要:
Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals. For exampl 阅读全文
摘要:
How do we solve problem like this if we were given a normal tree? Yes, traverse it, keep a root to leaf running sum. If we see a leaf node (node.left 阅读全文
摘要:
The general solution would be to check each char in turn and report the first char that makes the string a non number. There are some exceptions to wa 阅读全文