上一页 1 2 3 4 5 6 ··· 20 下一页
摘要: 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... 阅读全文
posted @ 2015-10-19 23:53 jianchao-li 阅读(1604) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-10-17 00:20 jianchao-li 阅读(6519) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-10-15 13:54 jianchao-li 阅读(6190) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-10-13 16:41 jianchao-li 阅读(207) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given apatternand a stringstr, find ifstrfollows the same pattern.Herefollowmeans a full match, such that there is a bijection bet... 阅读全文
posted @ 2015-10-12 00:08 jianchao-li 阅读(4986) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-10-06 22:10 jianchao-li 阅读(419) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-10-04 00:59 jianchao-li 阅读(698) 评论(0) 推荐(0) 编辑
摘要: Problem Description:An abbreviation of a word follows the form . Below are some examples of word abbreviations:a) it --> it (n... 阅读全文
posted @ 2015-10-02 00:30 jianchao-li 阅读(4231) 评论(0) 推荐(0) 编辑
摘要: There are mainly two solutions to solve this problem.The first one is very clever, using the idea of cycle detection, and runs in O(n) time. You may r... 阅读全文
posted @ 2015-09-28 17:26 jianchao-li 阅读(381) 评论(0) 推荐(0) 编辑
摘要: Problem Description:You are given am x n2D grid initialized with these three possible values.-1- A wall or an obstacle.0- A gate.INF- Infinity means a... 阅读全文
posted @ 2015-09-24 20:57 jianchao-li 阅读(3896) 评论(0) 推荐(1) 编辑
摘要: Problem Description:Given a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has no in... 阅读全文
posted @ 2015-09-22 15:59 jianchao-li 阅读(3569) 评论(0) 推荐(0) 编辑
摘要: An interesting problem about iterators. This post shares a very nice solution, which is rewritten below, with minor simplifications.// Below is the in... 阅读全文
posted @ 2015-09-21 12:18 jianchao-li 阅读(382) 评论(0) 推荐(0) 编辑
摘要: This post shares a very nice solution, which is rewritten below. 1 class Solution { 2 public: 3 vector addOperators(string num, int target) { 4 ... 阅读全文
posted @ 2015-09-16 21:58 jianchao-li 阅读(463) 评论(0) 推荐(0) 编辑
摘要: The key challenge to this problem is to make the code clean. This post has shared a nice example, which is rewritten below in C++.class Solution {publ... 阅读全文
posted @ 2015-09-14 14:53 jianchao-li 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 =... 阅读全文
posted @ 2015-09-14 14:16 jianchao-li 阅读(2466) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 20 下一页