Tony's Log

Algorithms, Distributed System, Machine Learning

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

随笔分类 -  HackerRank

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

摘要:The answer byTuxdudeis perfect:http://stackoverflow.com/questions/11161465/existence-of-a-permutation-under-constraints-interview-street-manipulative-... 阅读全文
posted @ 2015-06-10 02:26 Tonix 阅读(284) 评论(0) 推荐(0)

摘要:More on data structure.#include #include #include #include #include #include #include #include using namespace std;typedef pair Point;struct DistComp{... 阅读全文
posted @ 2015-06-09 09:34 Tonix 阅读(256) 评论(0) 推荐(0)

摘要:Classic and challenging DP! And you need combine several tricks together with DP to make it 100% pass.My main reference is here:https://github.com/hav... 阅读全文
posted @ 2015-06-09 05:10 Tonix 阅读(1216) 评论(0) 推荐(0)

摘要:Not hard, but with some amount of coding. Brutal-force would work: iterate each unique pair of points. And I used "y=ax+b" to check each point which s... 阅读全文
posted @ 2015-06-05 03:50 Tonix 阅读(224) 评论(0) 推荐(0)

摘要:import reimport ioimport sysinput_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')s = input_stream.readlines()s = "\n".join(s)pc = '(//.*... 阅读全文
posted @ 2015-06-03 07:34 Tonix 阅读(622) 评论(0) 推荐(0)

摘要:So fun! It connects algorithm(regex) with real world usages!So basically speaking, C:pointer syntax, #include\scanf\typedef; Java: import\public class... 阅读全文
posted @ 2015-06-03 07:09 Tonix 阅读(734) 评论(0) 推荐(0)

摘要:Really fun regex one.import ren = int(input())txt = ''for _ in range(n): str = input() txt = txt + strdict = {}all = re.findall(']*>', txt)for i... 阅读全文
posted @ 2015-06-03 02:13 Tonix 阅读(179) 评论(0) 推荐(0)

摘要:A relatively more complex regex problem to work on. It is fun!import ren = input()for _ in range(n): str = raw_input() pl = '[+-]?([1-8]?[0-9]([... 阅读全文
posted @ 2015-06-01 13:57 Tonix 阅读(502) 评论(0) 推荐(0)

摘要:Pretty classic greedy problem to work on. Here is how to approach it:1. "the smallest team is as large as possible." actually means, team members shou... 阅读全文
posted @ 2015-06-01 11:13 Tonix 阅读(263) 评论(0) 推荐(0)

摘要:My intuition told me that it is a line-scan process.. and yes it is. First, we sort all (a,b,k) by index\start-end, then we do a line scan. And in C++... 阅读全文
posted @ 2015-06-01 09:57 Tonix 阅读(434) 评论(0) 推荐(0)

摘要:Note this smart observation from Editorial: "M will be either P or Q or (A_i+A_j)/2"..Yea I know, my code is not condense enough..#include #include #i... 阅读全文
posted @ 2015-06-01 08:27 Tonix 阅读(246) 评论(0) 推荐(0)

摘要:I guess the punch line of this one is Sieving for primes.#include #include #include #include #include #include #include #include using namespace std;v... 阅读全文
posted @ 2015-05-28 01:48 Tonix 阅读(263) 评论(0) 推荐(0)

摘要:Apparently it is by a backwards derivation solution. Say energy at h[i] is e, the next energy at h[i+1] is 2*e - h[i+1] => e', so backwards, e = ceil(... 阅读全文
posted @ 2015-05-27 07:03 Tonix 阅读(264) 评论(0) 推荐(0)

摘要:We match larger in array_a with smaller in array_b, by which we can have as even sum as possible, so we don't have too small sums.#include #include #i... 阅读全文
posted @ 2015-05-27 00:44 Tonix 阅读(143) 评论(0) 推荐(0)

摘要:Apparently, more expensive flowers should be bought with lower coeff. (Greedy part), and any unbalanced assignment would cause extra cost.So the code ... 阅读全文
posted @ 2015-05-26 14:16 Tonix 阅读(155) 评论(0) 推荐(0)

摘要:It is modulo version of "max sum of contiguous subarray". So similar pattern can be applied too, but with tricks regarding to modulo ops.I checked edi... 阅读全文
posted @ 2015-05-22 14:19 Tonix 阅读(656) 评论(0) 推荐(0)

摘要:Good one to learn Binary Indexed Tree (Fenwick Tree). Simply grabbed the editorial's code but with comments.#include #include #include #include #inclu... 阅读全文
posted @ 2015-05-21 07:34 Tonix 阅读(280) 评论(0) 推荐(0)

摘要:An ACM-level problem because it involves "advanced maths". It should not be marked as "Moderate". Other than that, it is a medium level DP one.*Math m... 阅读全文
posted @ 2015-05-19 10:53 Tonix 阅读(272) 评论(0) 推荐(0)

摘要:This is my 1st 3D DP problem, and it should be an educational one. But, still tricky to me.Here is a good article:http://www.cnblogs.com/sunshineatnoo... 阅读全文
posted @ 2015-05-15 15:49 Tonix 阅读(256) 评论(0) 推荐(0)

摘要:Solution 1:https://www.hackerrank.com/challenges/number-list/editorialReversed thought: total no. of subsets - no. of subsets without arr[i] > kSoluti... 阅读全文
posted @ 2015-05-11 05:08 Tonix 阅读(187) 评论(0) 推荐(0)

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