Tony's Log

Algorithms, Distributed System, Machine Learning

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

2015年5月10日

摘要: It requires O(nlgn) solution. And actually I think the passing code is for "non-decreasing"..#include #include #include #include #include #include #in... 阅读全文
posted @ 2015-05-10 12:30 Tonix 阅读(222) 评论(0) 推荐(0)

2015年5月8日

摘要: Really interesting problem. Naive solution would be O(n^3). But please note the pattern here: (i, j, k) -> (i + 1, j + 1, k) -> (i + 2, j + 2, k)... t... 阅读全文
posted @ 2015-05-08 07:23 Tonix 阅读(469) 评论(0) 推荐(0)

2015年4月30日

摘要: My first reaction was, total No. of strings - no. of palindromic strings. But looks like counting all palindromic strings is not that easy.. So it has... 阅读全文
posted @ 2015-04-30 15:30 Tonix 阅读(244) 评论(0) 推荐(0)

摘要: Please note input constraints. String length will not exceed 100, which means, we can use relatively naive representation\calculation for anagrams: so... 阅读全文
posted @ 2015-04-30 13:29 Tonix 阅读(476) 评论(0) 推荐(0)

摘要: Sieve of Eratosthenesclass Solution {public: int countPrimes(int n) { if(n rec(n + 1, false); int bound = floor(sqrt(n)); i... 阅读全文
posted @ 2015-04-30 01:04 Tonix 阅读(142) 评论(0) 推荐(0)

2015年4月27日

摘要: Simplied a DFS\BFS with minor modification.#include #include #include #include #include #include using namespace std;typedef vector> Matrix;typedef pa... 阅读全文
posted @ 2015-04-27 14:16 Tonix 阅读(545) 评论(0) 推荐(0)

摘要: Typical tree recursion works. The key is: ANY node can be treated as the root, since it is about edge, not about node. This simplifies things a lot.#i... 阅读全文
posted @ 2015-04-27 14:14 Tonix 阅读(238) 评论(0) 推荐(0)

2015年4月23日

摘要: This is a super interesting bit problem. This link can be found in discussion panel:http://math.stackexchange.com/questions/712487/finding-xor-of-all-... 阅读全文
posted @ 2015-04-23 05:18 Tonix 阅读(437) 评论(0) 推荐(0)

2015年4月20日

摘要: Intuitive coding problem. But several details to take care.#include #include #include #include #include #include #include using namespace std;bool pla... 阅读全文
posted @ 2015-04-20 07:34 Tonix 阅读(210) 评论(0) 推荐(0)

2015年4月17日

摘要: Typical greedy\recursion algorithm.#include #include #include #include #include #include using namespace std;struct Node{ Node() : pinx(0), nodeCnt... 阅读全文
posted @ 2015-04-17 14:16 Tonix 阅读(327) 评论(0) 推荐(0)

2015年4月16日

摘要: Really interesting problem! My 1st solution was DP based, like bottom-up pattern, but it got TLE since it is O(n^2). Then I thought there must be a O(... 阅读全文
posted @ 2015-04-16 14:52 Tonix 阅读(398) 评论(0) 推荐(0)

摘要: Just picture the shifting process in your mind..class Solution {public: int rangeBitwiseAnd(int m, int n) { if (m == n) return m; int... 阅读全文
posted @ 2015-04-16 12:52 Tonix 阅读(118) 评论(0) 推荐(0)

摘要: A coding problem. The trick is, some part of computation can be reused from last iteration. Check out my code:#include #include #include #include #inc... 阅读全文
posted @ 2015-04-16 12:30 Tonix 阅读(317) 评论(0) 推荐(0)

摘要: I tried Python:def f(x,i,n,a,b,r,s,w): if(i>n):return r return f(x,i+1,n,a*x*x,b*2*i*(2*i+s),r+a*w/b,s,-w)n=int(input())for _ in range(n): v=... 阅读全文
posted @ 2015-04-16 10:18 Tonix 阅读(187) 评论(0) 推荐(0)

2015年4月13日

摘要: I saw a lot of BFS based solutions. And my alternative solution is this mirror-ed BST iterator one, with some book-keeping:class Solution {public: ... 阅读全文
posted @ 2015-04-13 11:28 Tonix 阅读(171) 评论(0) 推荐(0)

2015年4月7日

摘要: Floyd-Warshall算法其实是比较容易理解也比较容易coding的DP... 不说了,上代码:#include #include #include #include #include #include #include #include #include using namespace st... 阅读全文
posted @ 2015-04-07 13:19 Tonix 阅读(142) 评论(0) 推荐(0)

2015年4月3日

摘要: HihoCoder上有两道背包问题的problem,http://hihocoder.com/problemset/problem/1038 (01背包)#include #include #include #include #include #include #include using name... 阅读全文
posted @ 2015-04-03 05:05 Tonix 阅读(228) 评论(0) 推荐(0)

2015年3月25日

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

2015年3月21日

摘要: 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)

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