Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 25 下一页

2015年3月20日

摘要: 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 阅读(246) 评论(0) 推荐(0)

2015年3月19日

摘要: 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 阅读(282) 评论(0) 推荐(0)

2015年3月18日

摘要: "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 阅读(333) 评论(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 阅读(260) 评论(0) 推荐(0)

2015年3月16日

摘要: 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 阅读(417) 评论(0) 推荐(0)

2015年3月12日

摘要: 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 阅读(296) 评论(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 阅读(174) 评论(0) 推荐(0)

2015年3月5日

摘要: 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 阅读(159) 评论(0) 推荐(0)

2015年3月3日

摘要: 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 阅读(278) 评论(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 阅读(232) 评论(0) 推荐(0)

2015年3月2日

摘要: 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 阅读(197) 评论(0) 推荐(0)

2015年2月28日

摘要: All about pruning and duplication removal. Took me several submissions to get it AC:#include #include #include #include #include #include using namesp... 阅读全文
posted @ 2015-02-28 07:52 Tonix 阅读(181) 评论(0) 推荐(0)

2015年2月27日

摘要: An iterative 'simulation' problem:#include #include #include #include #include using namespace std;int main() { int t, n, c, m; cin >> t; whi... 阅读全文
posted @ 2015-02-27 15:10 Tonix 阅读(153) 评论(0) 推荐(0)

摘要: The punch line to this problem is the support to very very large int handling. I tried C++ code for multiple times, but it only passed first 13~ cases 阅读全文
posted @ 2015-02-27 14:58 Tonix 阅读(153) 评论(0) 推荐(0)

摘要: You may also have seen this problem in interview questions. Two cases:1. all chars have even numbers of it2. only 1 char have odd numbers of it#includ... 阅读全文
posted @ 2015-02-27 07:05 Tonix 阅读(173) 评论(0) 推荐(0)

摘要: https://www.hackerrank.com/challenges/angry-childrenAmong N ints, pick K with min 'unfairness' (max of k - min of k). Here's the strategy: larger numb... 阅读全文
posted @ 2015-02-27 06:47 Tonix 阅读(538) 评论(0) 推荐(0)

2015年2月9日

摘要: Typical rolling-hash solution. That is, Boyer-Moore algorithm variation.class Solution {public: inline int encode(char c) { switch (c) ... 阅读全文
posted @ 2015-02-09 08:29 Tonix 阅读(367) 评论(0) 推荐(0)

2015年1月27日

摘要: Details not refined yet..struct Ret{ Ret(TreeNode *p, Mask rm) : pVal(p), m(rm){} TreeNode *pVal; Mask m;};class Solution {public: Ret lca... 阅读全文
posted @ 2015-01-27 06:39 Tonix 阅读(193) 评论(0) 推荐(0)

2015年1月18日

摘要: - G: a vector of strings, find a pair with max of strlen(a) * strlen(b) 1. O(n*k): get std::bitset() of each string 2. O(nlgn): sort strings by leng... 阅读全文
posted @ 2015-01-18 11:22 Tonix 阅读(172) 评论(0) 推荐(0)

2015年1月15日

摘要: [Technical]1. difference btw. realloc() and free(): realloc() simply changes the size of a mem2. More about TCP\IP, its flow control[Behavior]1. be mo... 阅读全文
posted @ 2015-01-15 14:15 Tonix 阅读(90) 评论(0) 推荐(0)

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 25 下一页