public int[] setMax(int[] prices){
        if(prices == null || prices.length==1){return prices;}
        int[] maxValues = new int[prices.length];
        for(int i=0;i<prices.length-1;i++){     // the last price can't be the price to buy
            int max = 0;
            int maxPos = 0;
            for(int j=i+1;j<prices.length;j++){
                if(prices[j]>max){
                    max = prices[j];
                    maxPos = j;
                }
            }
            //max = max(i,prices.length);
            //maxPos = j;
            for(int k=i;k<maxPos;k++){          //so at least 2 elements
                maxValues[k]=maxPos;
            }
            if(prices[i]>=max){
                maxValues[i]= -1;
            }
            maxValues[maxPos] = -1;
            if(maxPos!=0){			//as 0 is the initialization value and can't be sell price
            	i=maxPos;			//pay attention to initialization value and for loop will +1, next time;
            }
        }
        return maxValues;
    }