Guest User

Untitled

a guest
Feb 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. package com.tvidushi.arrays;
  2.  
  3. import java.util.stream.Stream;
  4.  
  5. /**
  6. * An Array element is considered peaj ,if it is not
  7. * smaller than its neigbours
  8.  
  9. */
  10. public class PeakElement {
  11.  
  12. public static void main(String[] args) {
  13.  
  14. int num [] = {10,20,15,2,23,90,67};
  15.  
  16. for(int i= 1; i<num.length-1;i++){
  17. if(num[i-1]<num[i] && num[i+1]<num[i]){
  18. System.out.println("Peak element are "+num[i]);
  19. }
  20. }
  21. }
  22. }
Add Comment
Please, Sign In to add comment