Tony's Log

Algorithms, Distributed System, Machine Learning

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

2015年6月23日

摘要: Yes just an implementation problem.. a lot of typing work.#include #include #include #include #include #include #include #include #include #include us... 阅读全文
posted @ 2015-06-23 05:28 Tonix 阅读(296) 评论(0) 推荐(0)

2015年6月22日

摘要: Comparing with the 'I' one, there are two changes:1. if last operator is "+" or "-", we don't evaluate expression2. if last operator is "*" or "/", we... 阅读全文
posted @ 2015-06-22 12:14 Tonix 阅读(174) 评论(0) 推荐(0)

2015年6月19日

摘要: 1st Try: brutal-force solution failed 3 test cases with TLE2nd Try: uint32_t bucketing - AC:#include #include #include #include #include #include #inc... 阅读全文
posted @ 2015-06-19 04:41 Tonix 阅读(306) 评论(0) 推荐(0)

2015年6月18日

摘要: This one is marked as "Advanced".. i don't tink so, not that hard if you can visualize all the bits from a to b. Two key points here:1. Say both a and... 阅读全文
posted @ 2015-06-18 10:03 Tonix 阅读(374) 评论(0) 推荐(0)

2015年6月16日

摘要: Two-queue solutionclass Stack { queue q; queue q0; int _top;public: // Push element x onto stack. void push(int x) { q.push(x); ... 阅读全文
posted @ 2015-06-16 04:35 Tonix 阅读(141) 评论(0) 推荐(0)

2015年6月10日

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

2015年6月9日

摘要: My first try was DFS by intuition, but it ended up with MLE. So, the expected solution is to use stack:class Solution { struct Node { Nod... 阅读全文
posted @ 2015-06-09 13:41 Tonix 阅读(470) 评论(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 阅读(255) 评论(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 阅读(1215) 评论(0) 推荐(0)

2015年6月6日

摘要: DFS solution is intuitive. I put my BFS solution below:class Solution {public: int countNodes(TreeNode* root) { if (!root) return 0; ... 阅读全文
posted @ 2015-06-06 05:35 Tonix 阅读(304) 评论(0) 推荐(0)

2015年6月5日

摘要: Lesson learnt: std::multiset is a heap structure supporting random removal...class Solution { public: bool containsNearbyAlmostDuplicate(vec... 阅读全文
posted @ 2015-06-05 07:41 Tonix 阅读(149) 评论(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 阅读(221) 评论(0) 推荐(0)

2015年6月3日

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

2015年6月1日

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

2015年5月30日

摘要: Maintain a hashset with size of (K + 1)class Solution {public: bool containsNearbyDuplicate(vector& nums, int k) { unordered_set hs; ... 阅读全文
posted @ 2015-05-30 01:36 Tonix 阅读(161) 评论(0) 推荐(0)

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