Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static long getSum(Long[] list, int level, int start, int end){
- System.out.println("Start: "+start+"End: "+end);
- if(start>end)
- return 0;
- if(start==end){
- if(level%2==0){
- return list[start];
- }
- return 0;
- }
- int i;
- for(i=start+1;i<end;i++){
- if(list[i]>list[start]){
- break;
- }
- }
- if(level%2==0){
- return list[start]+getSum(list,level+1,start+1,i-1)+getSum(list,level+1,i,end);
- }
- return getSum(list,level+1,start+1,i-1)+getSum(list,level+1,i,end);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement