-
Recent Posts
Archives
calendar
December 2025 M T W T F S S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Categories
Meta
Tag Cloud
Author Archives: codingfan
subarry with sum of 0
Q: An array contain positive and negative elements, find maximum subarray whose sum is equal to zero. Algorithm: Lets take input array as a[]={-3,2,4,-6,-8,10,11} Make an array b [] such that b[i]=b[i-1]+a[i]; means b[i] = sum(a[0],…, a[i]); So b[]={-3,-1,3,-3,-11,-1,10} Now … Continue reading
Posted in Uncategorized
Leave a comment
check if a tree is a bst
int inorderCheck( TreeNode *root, int *last ) { if( root == NULL ) { *last = INT_MIN; return 1; } int left = inorderCheck( root->left, last ); if( root->data > *last && *last != null ) { *last = root->data; … Continue reading
find kth element by min heap
//copyright@ 泡泡鱼 //July、2010.06.02。 //@lingyun310:先对元素数组原地建最小堆,O(n)。然后提取K次,但是每次提取时, //换到顶部的元素只需要下移顶多k次就足够了,下移次数逐次减少。此种方法的复杂度为O(n+k^2)。 #include <stdio.h> #include <stdlib.h> #define MAXLEN 10 #define K 3 // void HeapAdjust(int array[], int i, int Length) { int child,temp; for(temp=array[i];2*i+1<Length;i=child) { child = 2*i+1; if(child<Length-1 && … Continue reading
Posted in Uncategorized
Leave a comment
given in-order and pre-order, re-construct a tree
Here is my code : // In-order traversal : c b f d g a e (Left, Root, Right)// Pre-order traversal : a b c d f g e. (Root, left, right)//// static int rootIdx = 0; public Node … Continue reading
找最小的K个数 – Stay hungry, Sta y foolish – 博客频道 – CSDN.NET
From Evernote: 找最小的K个数 – Stay hungry, Stay foolish – 博客频道 – CSDN.NET Clipped from: http://blog.csdn.net/huagong_adu/article/details/6901924
Posted in Uncategorized
Leave a comment
top coder
Difference between forward and sendRedirect
Difference between forward and sendRedirect13/05/2008forward Control can be forward to resources available within the server from where the call is made. This transfer of control is done by the container internally and browser / client is not involved. This is … Continue reading
Posted in Uncategorized
Leave a comment
012年各大公司H1B工资全记录
来源http://www.foreignlaborcert.doleta.gov/pdf/quarter_2_2012/LCAFY http://www.mitbbs.com/article_t/JobHunting/32247711.html 表格上工资有两项,一个是Employer’s proposed wage rate,另一个是max wage rate. 如果max那项值不为零,那就不在统计范围内。 Amazon SDE1: avg = 96k, num = 42 SDE2: avg = 108k num = 53 SDE3: avg = 133k num = 3 EBay Soft. Eng. 2 avg = 95k num … Continue reading
Posted in Uncategorized
Leave a comment