Tony's Log

Algorithms, Distributed System, Machine Learning

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

2017年1月6日

摘要: Fun one.. the punch line of this problem is quite common in Bit related problems on HackerRank - visualize it in your mind, and you will find: all bit 阅读全文
posted @ 2017-01-06 12:19 Tonix 阅读(109) 评论(0) 推荐(0)

摘要: My first reaction is to have an unlimited length of bit-array, to mark existence. But if no extra mem is allowed, we can simply use 'sign' on each ind 阅读全文
posted @ 2017-01-06 08:31 Tonix 阅读(114) 评论(0) 推荐(0)

摘要: The follow-up question is fun: "Could you do it in one-pass, using only O(1) extra memory and without modifying the value of the board?" When we meet 阅读全文
posted @ 2017-01-06 07:11 Tonix 阅读(132) 评论(0) 推荐(0)

2016年11月12日

摘要: Increasing all elements by 1 except one element, equals to decreasing that one element. 阅读全文
posted @ 2016-11-12 11:57 Tonix 阅读(93) 评论(0) 推荐(0)

2016年11月5日

摘要: Straight-forward strategy.. please take care of all details - data type, assignment order etc. 阅读全文
posted @ 2016-11-05 13:23 Tonix 阅读(96) 评论(0) 推荐(0)

2016年10月31日

摘要: A simple math.. take care of data overflow though. 阅读全文
posted @ 2016-10-31 10:55 Tonix 阅读(94) 评论(0) 推荐(0)

2016年10月24日

摘要: There are 3 possible approaches: DP, divide&conquer and greedy. And apparently, DP has O(n^2) complexity (TLE), DivideConquer can only be worse. Greed 阅读全文
posted @ 2016-10-24 03:25 Tonix 阅读(96) 评论(0) 推荐(0)

2016年8月7日

摘要: A bit Greedy can achieve O(m) - the mid station between 2 adjacent cities has the longest distance within that range. 阅读全文
posted @ 2016-08-07 13:53 Tonix 阅读(273) 评论(0) 推荐(0)

2016年7月24日

摘要: A simple math on modular calculations.Code below can be simplified of course. 阅读全文
posted @ 2016-07-24 07:56 Tonix 阅读(214) 评论(0) 推荐(0)

摘要: Another interesting DP. Lesson learnt: how you define state is crucial.. 1. if DP[i] is defined as, longest wiggle(up\down) subseq AT number i, you wi 阅读全文
posted @ 2016-07-24 07:31 Tonix 阅读(320) 评论(0) 推荐(0)

2016年7月21日

摘要: DP or Greedy - they are all in O(n) In editorial, a beautiful Greedy solution is given: "To reach the last cloud in a minimum number of steps, always 阅读全文
posted @ 2016-07-21 09:31 Tonix 阅读(325) 评论(0) 推荐(0)

2016年7月13日

摘要: Another fun Greedy problem to work on: we simply go from first to second last person, as long someone is odd, we distribute bread to her and her next. 阅读全文
posted @ 2016-07-13 07:42 Tonix 阅读(331) 评论(0) 推荐(0)

摘要: Greedy - though simple, but fun! 阅读全文
posted @ 2016-07-13 07:17 Tonix 阅读(347) 评论(0) 推荐(0)

2016年7月7日

摘要: Fun with bits - carries etc. 阅读全文
posted @ 2016-07-07 07:59 Tonix 阅读(105) 评论(0) 推荐(0)

2016年6月30日

摘要: I use a stack. Of course you can simply trace nodes with 9s - https://leetcode.com/discuss/111127/iterative-two-pointers-with-dummy-node-java-o-n-time 阅读全文
posted @ 2016-06-30 01:53 Tonix 阅读(261) 评论(0) 推荐(0)

2016年6月28日

摘要: A mix of hashmap, list and heap. struct Tw { Tw(long long pts, int tid) { ts = pts; tweetid = tid; } long long ts; int tweetid; }; struct Cmp { bool o 阅读全文
posted @ 2016-06-28 01:56 Tonix 阅读(238) 评论(0) 推荐(0)

摘要: Hits come and go - so we use queue. Nothing special. 阅读全文
posted @ 2016-06-28 01:03 Tonix 阅读(181) 评论(0) 推荐(0)

2016年6月27日

摘要: Very nice DP problem. The key fact of a mutual-divisible subset: if a new number n, is divisible with the largest number m within a mutual-divisible s 阅读全文
posted @ 2016-06-27 13:20 Tonix 阅读(344) 评论(0) 推荐(0)

摘要: Typical DFS problem. Simply get higher height and push_back. 阅读全文
posted @ 2016-06-27 11:35 Tonix 阅读(167) 评论(0) 推荐(0)

摘要: Typical binary search.. but take care of data overflow if you are using C++ 阅读全文
posted @ 2016-06-27 11:21 Tonix 阅读(185) 评论(0) 推荐(0)

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