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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include<cstdlib> class StockSpanner { private: int* arr=NULL; int* nextInt=NULL; int size; public: StockSpanner() { if(arr==NULL){ arr=(int*)malloc(sizeof(int)*10000); } if(nextInt==NULL){ nextInt=(int*)malloc(sizeof(int)*10000); } size=0; } int next(int price) { arr[size]=price; if(size==0){ nextInt[size]=1; size=1; return 1; } int ret; int i; for(i=size-1;i>=0;){ if(arr[i]<=price){ i-=nextInt[i]; } else{ break; } } ret=size-i; if(i>=0&&arr[i]<=price){ ret++; } nextInt[size]=ret; size++; return ret; } }; |
Do you want to hit the jackpot in your SEO efforts? this online marketing offer is for you. I offer you the most advance and safe link building method thrive to your site top SERPS and traffic to your Website or Video.
Do you want to hit the jackpot in your SEO efforts? this online marketing offer is for you. I offer you the most advance and safe link building method thrive to your site top SERPS and traffic to your Website or Video.