Tony's Log

Algorithms, Distributed System, Machine Learning

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

03 2015 档案

摘要:One sentence in the problem statement is crucial "your friend will also play optimally", if you interpret it correctly, you are very close to AC. What... 阅读全文
posted @ 2015-03-25 06:24 Tonix 阅读(692) 评论(0) 推荐(0)

摘要:The code below is for:http://hihocoder.com/problemset/solution/237010With enough comments to understand:#include #include #include #include #include #... 阅读全文
posted @ 2015-03-25 02:03 Tonix 阅读(167) 评论(0) 推荐(0)

摘要:Classic DP, and requires you to track optimal path.len1, len2 = map(int, raw_input().strip().split())a = map(int, raw_input().strip().split())b = map(... 阅读全文
posted @ 2015-03-21 13:45 Tonix 阅读(166) 评论(0) 推荐(0)

摘要:Kinda similar with another palindrome DP from LeetCode. Feel it, it is a bottom-up DP - palindrome subsequence.str = input()slen = len(str)dp = [[0 fo... 阅读全文
posted @ 2015-03-20 01:15 Tonix 阅读(243) 评论(0) 推荐(0)

摘要:Very good problem to learn knapsack (complete knapsack in this case).My brutal-force solution in Python got AC too, which surprised me a bit. Here is ... 阅读全文
posted @ 2015-03-19 05:11 Tonix 阅读(280) 评论(0) 推荐(0)

摘要:"How many inverted pairs" - that usually ends up with MergeSort solution (of course there are other solutions out there)def mergeSort(arr): if len(... 阅读全文
posted @ 2015-03-18 03:42 Tonix 阅读(331) 评论(0) 推荐(0)

摘要:Nothing special, just some corner casesn = int(input())arr = [int(i) for i in input().strip().split()]# Collect rec = []i = 0while i arr[i + 1]: ... 阅读全文
posted @ 2015-03-18 03:01 Tonix 阅读(257) 评论(0) 推荐(0)

摘要:Longest Common Subsequence in disguise.Python impl. has TLE in one case. And C++ is fine.#include #include #include #include #include #include #includ... 阅读全文
posted @ 2015-03-16 14:12 Tonix 阅读(413) 评论(0) 推荐(0)

摘要:This is a very smart observation:http://www.martinkysel.com/hackerrank-sherlock-and-gcd-solution/# http://www.martinkysel.com/hackerrank-sherlock-and-... 阅读全文
posted @ 2015-03-12 05:42 Tonix 阅读(294) 评论(0) 推荐(0)

摘要:Counting number of enabled bits in uint32_t.. Here is a O(lg32) solution. Very smart, like bottom-up parallel tree post-order traversal.Solution from ... 阅读全文
posted @ 2015-03-12 01:41 Tonix 阅读(170) 评论(0) 推荐(0)

摘要:http://www.cnblogs.com/grenet/p/3145800.htmlBest elaboration on dancing list I found. in Chinese.Traditional backtracing is a heuristic-like procedure... 阅读全文
posted @ 2015-03-05 07:38 Tonix 阅读(156) 评论(0) 推荐(0)

摘要:Point: not necessarily contigous max sub array, at least one element should be selected:def maxSubarrCont(arr, n): ret = arr[0] curr = arr[0] ... 阅读全文
posted @ 2015-03-03 16:20 Tonix 阅读(275) 评论(0) 推荐(0)

摘要:In Haskell. Two points: 1. pruning 2. Int suffers from overflow. Integer it is.getPowerSum :: Integer -> [Integer] -> Integer -> IntegergetPowerSum _ ... 阅读全文
posted @ 2015-03-03 03:16 Tonix 阅读(227) 评论(0) 推荐(0)

摘要:Greedy beats DP this time...I tried several DP solutions first, but all failed with RE\TLE. If you 'feel' the problem, Greedy should be working:(A sol... 阅读全文
posted @ 2015-03-02 11:30 Tonix 阅读(194) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示