随笔分类 - Leetcode
摘要:// learn from https://discuss.leetcode.com/topic/6912/c-dp-solution ''' class Solution { public: int calculateMinimumHP(vector>& dungeon) { int m = dungeon.size(),n = dungeon[0].size(); ...
阅读全文
摘要:learn from DP
阅读全文
摘要:leetcode 022. Generate Parentheses "Concise recursive C++ solution" "The most concise solution I know ever" "My 4ms C++ solution without using recursi
阅读全文
摘要:class Solution { public: int strStr(string haystack, string needle) { if(needle.empty())return 0; //needle empty if(haystack.empty()) return -1; //haystack empty fo...
阅读全文
摘要://鬼晓得上下反转,对角翻转之后竟然正好顺时针九十度,数学事体育老师教的class Solution { public: void rotate(vector>& matrix) { if(matrix.size()==0)return ; int size=matrix.size(); for(int i=0;i<size/2;i++) ...
阅读全文
摘要://hashmap implement with STL class Solution { public: vector> groupAnagrams(vector& strs) { // sort(strs.begin(),strs.end()); //sort all the element map>hashmap; fo...
阅读全文
摘要:1 //water 2 class Solution { 3 public: 4 int removeElement(vector& nums, int val) { 5 for(vector::iterator it=nums.begin();it!=nums.end();) 6 { 7 if(*it == val)...
阅读全文
摘要:water class Solution { public: int removeDuplicates(vector& nums) { for(vector::iterator it=nums.begin();it!=nums.end();) { int cur=*it; it++; ...
阅读全文
摘要:居然把头插法写错了,debug了一个多小时 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL)
阅读全文
摘要:1 /* improvement on dealing with overflow accroding to this: 2 * https://discuss.leetcode.com/topic/57452/c-solution-beats-100 3 * 4 * be careful about the INT_MAX and INT_MIN 5 * this at...
阅读全文
摘要:1 /* a good way to predict overflow 2 * each time *10 must predict int overflow 3 * not only the last time to predict which will be wrong. 4 */ 5 clas
阅读全文
摘要:1 /* simple simulation algorithm 2 * we cann`t make sure the size of the string, 3 * so it had better to storage in vector. 4 * show[] to buffer the new order of the string 5 */ 6 class S...
阅读全文
摘要:o(n)算法地址:http://blog.163.com/zhaohai_1988/blog/static/2095100852012716105847112//* pivot varies when the size of substrig is even or odd * member function parameter varies according to the size of s...
阅读全文
摘要:1 ### Letcode 003: Longest Substring Without Repeating Characters 2 ``` 3 /* basic traverse the string 4 * set to predict there is no repeat char in the substring 5 * 6 * Time Limit Out 7 ...
阅读全文
摘要://Memory Limit Exceeded /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution ...
阅读全文
摘要:look the solution in java from explantation on leetcode
阅读全文