Tony's Log

Algorithms, Distributed System, Machine Learning

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

2015年5月29日

摘要: Good one. My first reaction to this problem is the same idea as this answer:https://leetcode.com/discuss/37365/accepted-c-solution-o-nlogn-using-maxhe... 阅读全文
posted @ 2015-05-29 01:44 Tonix 阅读(396) 评论(0) 推荐(0)

2015年5月28日

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

2015年5月27日

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

2015年5月26日

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

2015年5月25日

摘要: Typical recursion usage.class Solution { vector> ret; void dfs(vector curr, int currSum, int maxN, int n, int k) { // Ending ... 阅读全文
posted @ 2015-05-25 15:14 Tonix 阅读(235) 评论(0) 推荐(0)

2015年5月23日

摘要: To have "shortest" expanded palindrome, we should know the longest "heading" palindrome in original string, so that we can reuse as much part as possi... 阅读全文
posted @ 2015-05-23 02:17 Tonix 阅读(250) 评论(0) 推荐(0)

2015年5月22日

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

2015年5月21日

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

2015年5月20日

摘要: A high quality DP problem to work on. It is not an merely educational DP, it is subtle.Basic ideas: 1. Run original DP twice, 1st with num[0] selecte... 阅读全文
posted @ 2015-05-20 11:00 Tonix 阅读(442) 评论(0) 推荐(0)

摘要: Trie, again.class TrieNode {public: // Initialize your data structure here. TrieNode() : prev(nullptr), c(0), bIsLast(false) { } TrieNo... 阅读全文
posted @ 2015-05-20 04:32 Tonix 阅读(193) 评论(0) 推荐(0)

摘要: I'm glad to see that LeetCode has finally realized the importance of Trie.My C++ code can be further optimized..class TrieNode {public: // Initiali... 阅读全文
posted @ 2015-05-20 01:28 Tonix 阅读(263) 评论(0) 推荐(0)

2015年5月19日

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

2015年5月15日

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

摘要: This one lets you print out one topological sorted sequence. Either BFS or DFS works. But there are tricky details.This is my reference:https://leetco... 阅读全文
posted @ 2015-05-15 02:46 Tonix 阅读(220) 评论(0) 推荐(0)

2015年5月13日

摘要: O(n): Sliding window:class Solution {public: int minSubArrayLen(int s, vector& nums) { int len = nums.size(); if (len == 0) return... 阅读全文
posted @ 2015-05-13 15:43 Tonix 阅读(233) 评论(0) 推荐(0)

摘要: Topological sorting. This is my DFS solution. Please note that I used _rec to avoid duplicate checking.class Solution {public: map rec; set _rec... 阅读全文
posted @ 2015-05-13 14:37 Tonix 阅读(149) 评论(0) 推荐(0)

摘要: Implementation problem.class TrieNode {public: // Initialize your data structure here. TrieNode() { c = 0; bIsLast = false; } ... 阅读全文
posted @ 2015-05-13 13:28 Tonix 阅读(267) 评论(0) 推荐(0)

2015年5月11日

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

2015年5月10日

摘要: I treated it too difficult.. nothing special, just some optimization mentioned as:http://saraguru.weebly.com/how-i-solved/find-maximum-index-product-h... 阅读全文
posted @ 2015-05-10 14:12 Tonix 阅读(442) 评论(0) 推荐(0)

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