上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 36 下一页
摘要: Sorting solution O(nlogn): 1 class Solution { 2 public: 3 int maximumGap(vector &num) { 4 int len = num.size(), result = 0; 5 if (... 阅读全文
posted @ 2015-03-21 05:47 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(i... 阅读全文
posted @ 2015-03-21 05:00 keepshuatishuati 阅读(89) 评论(0) 推荐(0) 编辑
摘要: This is the extension of Largest Rectangle in Histogram. We can just project 2D matrix to 1D array and compute it line by line. 1 class Solution { 2 p... 阅读全文
posted @ 2015-03-21 04:58 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Notes:1. Do not forget to check xi == xj. It will cause INF.2. DO not forget to initialize the iterator. 1 /** 2 * Definition for a point. 3 * struc... 阅读全文
posted @ 2015-03-20 09:00 keepshuatishuati 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 1. Use memory :In the question, it already stated that there must be a majority element. So discard empty situation.Also it needs the number, not the ... 阅读全文
posted @ 2015-03-20 08:37 keepshuatishuati 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 1 struct Node { 2 int key, value; 3 Node(int k, int v) : key(k), value(v) {} 4 }; 5 6 class LRUCache{ 7 private: 8 int size; 9 list ... 阅读全文
posted @ 2015-03-20 08:17 keepshuatishuati 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Notes:Do not forget to clean the total and rec. 1 class Solution { 2 public: 3 int longestValidParentheses(string s) { 4 int len = s.size(... 阅读全文
posted @ 2015-03-20 08:09 keepshuatishuati 阅读(106) 评论(0) 推荐(0) 编辑
摘要: For this problem, we are OK to use hash set, since no numbers are needed. 1 class Solution { 2 public: 3 int lengthOfLongestSubstring(string s) { ... 阅读全文
posted @ 2015-03-20 07:58 keepshuatishuati 阅读(122) 评论(0) 推荐(0) 编辑
摘要: At first beginning, I was trying to use hash set to record the characters. But I found that was wrong.Because if there are couple same chars, when you... 阅读全文
posted @ 2015-03-20 07:52 keepshuatishuati 阅读(128) 评论(0) 推荐(0) 编辑
摘要: O(n2): 1 class Solution { 2 public: 3 string getP(string s, int start, int end) { 4 while (start >= 0 && end result.size()) result = s1;1... 阅读全文
posted @ 2015-03-20 07:33 keepshuatishuati 阅读(106) 评论(0) 推荐(0) 编辑
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 36 下一页