Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
上一页 1 2 3 4 5 6 7 ··· 25 下一页

2017年2月10日

摘要: Medium? Seriously? Well again, always smart solutions out there: https://discuss.leetcode.com/topic/77889/3-line-python-solution 阅读全文
posted @ 2017-02-10 05:07 Tonix 阅读(196) 评论(0) 推荐(0)

2017年2月1日

摘要: Isn't it 'Easy'? 阅读全文
posted @ 2017-02-01 01:31 Tonix 阅读(158) 评论(0) 推荐(0)

2017年1月31日

摘要: It is a matter of hashmap use. For the follow-up: 阅读全文
posted @ 2017-01-31 08:06 Tonix 阅读(149) 评论(0) 推荐(0)

摘要: A more programming-like solution, is to hack the problem from simple: we try each possble base value, and see which 111..11 fits target number - using 阅读全文
posted @ 2017-01-31 07:35 Tonix 阅读(279) 评论(0) 推荐(0)

2017年1月28日

摘要: Check out this brilliant solution:https://discuss.leetcode.com/topic/70658/concise-java-solution-using-dp My first solution was a O(n^2) typical DP bo 阅读全文
posted @ 2017-01-28 15:24 Tonix 阅读(103) 评论(0) 推荐(0)

摘要: The punch line of this one: sum of leaves: pi..pj = root..pj - root..pi. 阅读全文
posted @ 2017-01-28 14:44 Tonix 阅读(130) 评论(0) 推荐(0)

2017年1月27日

摘要: Split it into 2 group of arrays, 2 arrays in each group. Then use hashmap. class Solution { public: int fourSumCount(vector<int>& A, vector<int>& B, v 阅读全文
posted @ 2017-01-27 07:45 Tonix 阅读(167) 评论(0) 推荐(0)

摘要: A natural stack based solution. Seriously, whey 'Medium'? /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * 阅读全文
posted @ 2017-01-27 06:21 Tonix 阅读(182) 评论(0) 推荐(0)

2017年1月26日

摘要: Check this out: https://discuss.leetcode.com/topic/76312/java-1-line-recursion-solution Neat thoughts with neat code. Bravo. Deserve to learn. 阅读全文
posted @ 2017-01-26 14:48 Tonix 阅读(198) 评论(0) 推荐(0)

2017年1月24日

摘要: Simple greedy thought .. satify each kid with minimum qualified cookie, from the least greedy kid.. 阅读全文
posted @ 2017-01-24 12:52 Tonix 阅读(172) 评论(0) 推荐(0)

摘要: Idea is, among all factors of the int, we pick the two that is the closest pair. And searching from sqrt(area) is a better idea: https://discuss.leetc 阅读全文
posted @ 2017-01-24 11:05 Tonix 阅读(203) 评论(0) 推荐(0)

2017年1月22日

摘要: I prefer shorter code, so this one:https://discuss.leetcode.com/topic/75448/memoization-c-solution Please note: we don't want to be too greedy - despe 阅读全文
posted @ 2017-01-22 12:08 Tonix 阅读(247) 评论(0) 推荐(0)

2017年1月21日

摘要: Yes the most concise solution is recursion.https://discuss.leetcode.com/topic/66165/very-concise-c-solution-for-general-binary-tree-not-only-bst Here 阅读全文
posted @ 2017-01-21 15:35 Tonix 阅读(133) 评论(0) 推荐(0)

2017年1月14日

摘要: Natural Greedy. Sort the array and pick the medium as target. 阅读全文
posted @ 2017-01-14 14:40 Tonix 阅读(103) 评论(0) 推荐(0)

摘要: Fun one. A matter of string generation by given rules. I know it can be much shorter.. but i'm lazy to do that. 阅读全文
posted @ 2017-01-14 13:50 Tonix 阅读(148) 评论(0) 推荐(0)

2017年1月10日

摘要: Mediocre solution is O(nlgn) by using max-heap - but, remember bucket sort? it is O(n) 阅读全文
posted @ 2017-01-10 13:12 Tonix 阅读(99) 评论(0) 推荐(0)

2017年1月9日

摘要: This problem reflects a key strategy when dealing with discrete problem space - split split split.. That' is to say, we check each house and find its 阅读全文
posted @ 2017-01-09 14:20 Tonix 阅读(109) 评论(0) 推荐(0)

2017年1月8日

摘要: Brutal force works - and a smarter way is to utilize KMP. The most popular two solutions are essentially the same - one is obvious KMP, and another on 阅读全文
posted @ 2017-01-08 09:26 Tonix 阅读(148) 评论(0) 推荐(0)

2017年1月7日

摘要: it is all about corner-cases... 阅读全文
posted @ 2017-01-07 09:06 Tonix 阅读(172) 评论(0) 推荐(0)

摘要: A trickier DFS, with a little bit complex recursion param tweak, and what's more important is pruning strategies.. or your code will TLE. 阅读全文
posted @ 2017-01-07 06:21 Tonix 阅读(164) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 25 下一页