10 2015 档案
摘要:This problem seems to be easy at the first glance, especially the problem gives a too much simpler example. Make sure you understand the problem by ma...
阅读全文
摘要:Problem Description:Given a binary tree, find the length of the longest consecutive sequence path.The path refers to any sequence of nodes from some s...
阅读全文
摘要:I adopt a way similar to that of the OJ to serialize the binary tree. For the following tree, my serialization result is "1,2,3,null,null,4,5," (note ...
阅读全文
摘要:Problem Description:A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, wher...
阅读全文
摘要:This post shares a very nice solution using two heaps: a max heap for the smaller half and a min heap for the larger half. The code is rewritten below...
阅读全文
摘要:Problem Description:You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+and-, you and yo...
阅读全文
摘要:Problem Description:You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+and-, you and yo...
阅读全文
摘要:Haha, an interesting problem. Just try to let your opponent start with a number that is an integer multiple of 4.1 class Solution {2 public:3 bool...
阅读全文
摘要:Problem Description:Given apatternand a stringstr, find ifstrfollows the same pattern.Herefollowmeans a full match, such that there is a bijection bet...
阅读全文
摘要:This problem can be solved in very neat codes (yeah, you will see Stefan posting many nice solutions).The solution in the above link is so nice that I...
阅读全文
摘要:A solution using additional spaces to solve a copy of the original board is easy. To get an in-place solution, we need to record the information of st...
阅读全文
摘要:Problem Description:An abbreviation of a word follows the form . Below are some examples of word abbreviations:a) it --> it (n...
阅读全文