摘要:
leetcode 022. Generate Parentheses "Concise recursive C++ solution" "The most concise solution I know ever" "My 4ms C++ solution without using recursi 阅读全文
摘要:
//hashmap implement with STL class Solution { public: vector> groupAnagrams(vector& strs) { // sort(strs.begin(),strs.end()); //sort all the element map>hashmap; fo... 阅读全文
摘要:
water class Solution { public: int removeDuplicates(vector& nums) { for(vector::iterator it=nums.begin();it!=nums.end();) { int cur=*it; it++; ... 阅读全文
摘要:
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... 阅读全文
摘要:
/*innner order traverse for BST will be ordered *1.sort the value in buffer *2.inner traverse the BST and insert the value *3.be careful for the forma 阅读全文
摘要:
//maximum and minimum 暴力遍历 O(n) //i-th element dicide and conquer random_selected_partition k(all the element samller than value[k] put left of value[ 阅读全文
摘要:
//intput array A,output array result. count array count . //all the elements is in te range of 0~k. //if k=O(n),the complexity is Θ(n) //counting sort 阅读全文
摘要:
//max_heap heap_maximum:return A[1] O(1); Extract_Heap_maximum:swap(A[1],A[heap.size]) adjust up to down from A[1] to hold the max_heap character O(lg 阅读全文
摘要:
//the first k elements interviewed and rejected, //for the latter n-k elements ,if value >max,return value, else return n'elements. #include<stdio.h># 阅读全文
摘要:
T(n)=aT(n/b)+f(n); where we can interpret n/b to mean either floor(b/n) or ceil(b/n), Then T (n) has the following asymptotic bounds: 1. If f (n)= O(n 阅读全文
摘要:
#include<stdio.h>#include<stdlib.h>#include<time.h>#define ARRAY_SIZE 1000int buf [ARRAY_SIZE];int main(){ srand((unsigned int )time(0)); int i,j,n; w 阅读全文