Advertisement
bai_onzi

Untitled

Feb 20th, 2023
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let array = gets().split(' ').map(Number);
  2. let isWaveForm = false;
  3.  
  4. for(let i = 1; i <= array.length; i+=2){
  5.     let currentNum = array[i];
  6.     let previousNum = array[i-1];
  7.     let nextNum = array[i+1];
  8.  
  9.     if(currentNum >= previousNum || currentNum >= nextNum){
  10.         isWaveForm = true;
  11.     }else{
  12.         isWaveForm = false;
  13.     }
  14. }
  15. if(!isWaveForm){
  16.     console.log('yes');
  17. }else{
  18.     console.log('no');
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement