Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tvidushi.arrays;
- import java.util.stream.Stream;
- /**
- * An Array element is considered peaj ,if it is not
- * smaller than its neigbours
- */
- public class PeakElement {
- public static void main(String[] args) {
- int num [] = {10,20,15,2,23,90,67};
- for(int i= 1; i<num.length-1;i++){
- if(num[i-1]<num[i] && num[i+1]<num[i]){
- System.out.println("Peak element are "+num[i]);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment