Author Archives: codingfan

100 囚犯放风问题(经典)

http://wapp.baidu.com/f?kz=69558066&lp=7200

Posted in Uncategorized | Leave a comment

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

Posted in Uncategorized | Tagged | Leave a comment

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

Posted in Uncategorized | Tagged | Leave a comment

找最小的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

http://www.cnblogs.com/AbandonZHANG/archive/2012/08/04/2622787.html     http://apps.topcoder.com/wiki/display/tc/Algorithm+Problem+Set+Analysis

Posted in Uncategorized | Tagged | Leave a comment

Store data in the HTML5 SQLite database

http://cookbooks.adobe.com/post_Store_data_in_the_HTML5_SQLite_database-19115.html

Posted in Uncategorized | Tagged | Leave a comment

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