摘要:
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() 阅读全文
摘要:
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 阅读全文