Tony's Log

Algorithms, Distributed System, Machine Learning

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

2016年4月7日

摘要: Great learning for me:https://www.hackerrank.com/rest/contests/master/challenges/lucky-numbers/hackers/turuthok/download_solution Basically it is memo 阅读全文
posted @ 2016-04-07 02:40 Tonix 阅读(313) 评论(0) 推荐(0)

2016年4月6日

摘要: Besides the common stack-based solutions, here is another recursive NestedIterator solution :) And here's my stack-based solution: 阅读全文
posted @ 2016-04-06 03:18 Tonix 阅读(270) 评论(0) 推荐(0)

2016年4月4日

摘要: A simple variation to "Longest Substring with At Most Two Distinct Characters". A typical sliding window problem. 阅读全文
posted @ 2016-04-04 02:53 Tonix 阅读(197) 评论(0) 推荐(0)

2016年4月1日

摘要: Nothing special. Just take care of corner cases. class Solution { public: /** * @param head a ListNode * @oaram v1 an integer * @param v2 an integer * 阅读全文
posted @ 2016-04-01 13:37 Tonix 阅读(176) 评论(0) 推荐(0)

2016年3月31日

摘要: An intuitive DFS one. 阅读全文
posted @ 2016-03-31 00:38 Tonix 阅读(135) 评论(0) 推荐(0)

2016年3月21日

摘要: Neat DP problem to go. If you don't like log(), you can use lookup table. And, this is an amazing solution: https://leetcode.com/discuss/93501/simple- 阅读全文
posted @ 2016-03-21 12:15 Tonix 阅读(137) 评论(0) 推荐(0)

2016年3月13日

摘要: Nice one. Try to learn the way of thinking, with the help of the below image: https://leetcode.com/discuss/89336/best-submission-searching-for-the-cro 阅读全文
posted @ 2016-03-13 15:02 Tonix 阅读(169) 评论(0) 推荐(0)

2016年3月12日

摘要: Recursion of course. But please make sure you cover all the cases. class Solution(object): # return: max value with node picked, max val w\o node pick 阅读全文
posted @ 2016-03-12 14:09 Tonix 阅读(139) 评论(0) 推荐(0)

摘要: Backtrace idea is straightforward. But there are always smarter solutions - like this: https://leetcode.com/discuss/87314/non-recursive-time-space-sol 阅读全文
posted @ 2016-03-12 08:15 Tonix 阅读(136) 评论(0) 推荐(0)

2016年3月10日

摘要: My first reaction was to use Manacher - which is O(n*k*k) - n is the no. of words, and k is the average length of words. Code of Manacher based soluti 阅读全文
posted @ 2016-03-10 14:57 Tonix 阅读(222) 评论(0) 推荐(0)

2016年2月17日

摘要: First problem to learn Max Flow. Ford-Fulkerson is a group of algorithms - Dinic is one of it.It is an iterative process: we use BFS to check augament 阅读全文
posted @ 2016-02-17 12:23 Tonix 阅读(372) 评论(0) 推荐(0)

2016年2月16日

摘要: Here is the mind flow: My intuition was to use Fenwick tree - that works but that's O(nlgn). That's too generalized and the magic number is 3 - that m 阅读全文
posted @ 2016-02-16 15:14 Tonix 阅读(135) 评论(0) 推荐(0)

2016年2月12日

摘要: A typical recursion use: class Solution(object): max_size = 0 # return: isValid, minVal, maxVal, nodeCnt def go(self, root): if root.left is None and 阅读全文
posted @ 2016-02-12 14:31 Tonix 阅读(274) 评论(0) 推荐(0)

2016年2月11日

摘要: Intuitive one to learn about Grundy basic :) Now every pile becomes a game, so we need to use Sprague-Grundy Theory. Calculation is quite intuitive - 阅读全文
posted @ 2016-02-11 09:04 Tonix 阅读(310) 评论(0) 推荐(0)

摘要: Please note: VROOK cannot go back-ward - that leads to a simple variation to Game of Nim: just XOR. t = int(input()) for _ in range(t): n = int(input( 阅读全文
posted @ 2016-02-11 05:15 Tonix 阅读(229) 评论(0) 推荐(0)

2016年2月3日

摘要: A variation to 0-1 Knapsack. (No Python code got fully AC. Python is too slow for this problem) #include <cmath> #include <cstdio> #include <vector> # 阅读全文
posted @ 2016-02-03 14:32 Tonix 阅读(414) 评论(0) 推荐(0)

摘要: https://leetcode.com/discuss/77133/o-n-o-1-after-median-virtual-indexing Please note the "interleaved" version of partial.. nice idea.. 阅读全文
posted @ 2016-02-03 12:36 Tonix 阅读(125) 评论(0) 推荐(0)

摘要: Yes a typical stack based problem. Please take care of corner cases. class Solution { public: bool isValidSerialization(string preorder) { // Get toke 阅读全文
posted @ 2016-02-03 06:08 Tonix 阅读(260) 评论(0) 推荐(0)

2016年2月1日

摘要: I got lost totally - it is a whole range of numbers! Actually, we can check each number within the range and pick it greedily. https://leetcode.com/di 阅读全文
posted @ 2016-02-01 05:49 Tonix 阅读(136) 评论(0) 推荐(0)

2016年1月28日

摘要: This is 'Difficult' - I worked out it within 45mins, and unlocked HackerRank Algorithm Level 80 yeah! So the idea is straight forward: 1. sort the inp 阅读全文
posted @ 2016-01-28 14:16 Tonix 阅读(318) 评论(0) 推荐(0)

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