Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int volume(int [] heights){
- int max =0;
- int min =0;
- int temp =0;
- for (int i=1;i<heights.length-1; i++){
- if(heights[i-1] > heights[i+1]){
- max = heights[i-1];
- min = heights[i+1];
- temp = i;
- }
- else{
- max = heights[i+1];
- min = heights[i-1];
- }
- System.out.println("index: " + temp
- + "max: " +max+
- "min: " +min);
- temp++;
- }
- return temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement