Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

随笔分类 -  HackerRank

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

摘要:Typical Floyd-Walshall Algorithm.#include #include #include #include #include #include #include #include #include using namespace std;const long DIST_... 阅读全文
posted @ 2015-08-03 01:52 Tonix 阅读(337) 评论(0) 推荐(0)

摘要:No big difference with "Breadth First Search: Shortest Reach", but this statement is crucial:If there are edges between the same pair of nodes with di... 阅读全文
posted @ 2015-08-02 15:18 Tonix 阅读(1179) 评论(0) 推荐(0)

摘要:Typical Dijstra algorithm impl. one.#include #include #include #include #include #include #include #include #include using namespace std;const long DI... 阅读全文
posted @ 2015-08-02 14:43 Tonix 阅读(1196) 评论(0) 推荐(0)

摘要:A combination of different DP passes.https://www.hackerrank.com/challenges/lego-blocks/editorial#include #include #include using namespace std;typedef... 阅读全文
posted @ 2015-08-02 05:31 Tonix 阅读(869) 评论(0) 推荐(0)

摘要:Classic.. just classic. It is a mix of Greedy and DP. The naive DP is, iterate over all [1..Bi] which is O(n^3). However, deeper thought into the prob... 阅读全文
posted @ 2015-07-21 15:40 Tonix 阅读(694) 评论(0) 推荐(0)

摘要:Interesting one.. It is more about data structure design actually. After you figure out how to represent cells, the DP formula will be very intuitive ... 阅读全文
posted @ 2015-07-20 12:15 Tonix 阅读(356) 评论(0) 推荐(0)

摘要:Actually I think it should belong to category of 'Bits Manipulation'.. but still, a really good one.My first reaction was, how to derive from a ^ (b #... 阅读全文
posted @ 2015-07-17 14:17 Tonix 阅读(356) 评论(0) 推荐(0)

摘要:Brutal-force solution is not hard to think about. But linear space input usually indicates O(n) DP solution.State design: dp[i]: total sum until index... 阅读全文
posted @ 2015-07-15 13:14 Tonix 阅读(393) 评论(0) 推荐(0)

摘要:My first thought made it unnecessarily difficult. Well, the correct solution falls into a typical pattern: use DP to calc cumulative results of each c... 阅读全文
posted @ 2015-07-14 05:02 Tonix 阅读(516) 评论(0) 推荐(0)

摘要:A typical bucketing strategy, but it is probably the most complex one..Basically I refer tothissubmission. 阅读全文
posted @ 2015-07-10 13:16 Tonix 阅读(299) 评论(0) 推荐(0)

摘要:First I was stuck at how to represent state of "add all except i".. but after checking editorial, it is simply inverted Coin Change problem..#include ... 阅读全文
posted @ 2015-07-07 05:38 Tonix 阅读(377) 评论(0) 推荐(0)

摘要:1AC. 1D DP + Sieving#include #include #include #include #include #include #include #include #include #include #include using namespace std;int ways(in... 阅读全文
posted @ 2015-07-03 06:58 Tonix 阅读(210) 评论(0) 推荐(0)

摘要:Good one.. marked as DP, so I was striking to work out a DP formula... well, not all DP have a formula - one type of DP is called memorized search: th... 阅读全文
posted @ 2015-07-02 14:08 Tonix 阅读(830) 评论(0) 推荐(0)

摘要:First I thought it should be solved using DP, and I gave a standard O(n^2) solution:#include #include #include #include using namespace std;#define RE... 阅读全文
posted @ 2015-07-01 07:10 Tonix 阅读(327) 评论(0) 推荐(0)

摘要:If coin order matters, that is, each sequence is unique, the DP function is simple enough to make it 1D DP. But key is that order DOESN'T matter, so w... 阅读全文
posted @ 2015-06-30 05:22 Tonix 阅读(467) 评论(0) 推荐(0)

摘要:The Editorial provides a Fast Fourier Transformation solution O(nlgn)... which is too maths for me. In the leaderboard, I found a not-that-fast O(n^2)... 阅读全文
posted @ 2015-06-25 14:14 Tonix 阅读(321) 评论(0) 推荐(0)

摘要:New techniques learnt: Trie can be used for some XOR problems. The basic idea: we build a MSB->LSB prefix Trie of all numbers; then query greedily: fi... 阅读全文
posted @ 2015-06-25 12:35 Tonix 阅读(345) 评论(0) 推荐(0)

摘要:Yes just an implementation problem.. a lot of typing work.#include #include #include #include #include #include #include #include #include #include us... 阅读全文
posted @ 2015-06-23 05:28 Tonix 阅读(299) 评论(0) 推荐(0)

摘要:1st Try: brutal-force solution failed 3 test cases with TLE2nd Try: uint32_t bucketing - AC:#include #include #include #include #include #include #inc... 阅读全文
posted @ 2015-06-19 04:41 Tonix 阅读(306) 评论(0) 推荐(0)

摘要:This one is marked as "Advanced".. i don't tink so, not that hard if you can visualize all the bits from a to b. Two key points here:1. Say both a and... 阅读全文
posted @ 2015-06-18 10:03 Tonix 阅读(375) 评论(0) 推荐(0)

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