Advertisement
boris-ivanov

Untitled

Mar 1st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. const getGets = (arr) => {
  2. let index = 0;
  3.  
  4. return () => {
  5. const toReturn = arr[index];
  6. index += 1;
  7. return toReturn;
  8. };
  9. };
  10. // this is the test
  11. const test = [
  12. '7',
  13. '-26 -25 -28 31 2 27 5',
  14. ];
  15.  
  16. const gets = this.gets || getGets(test);
  17. const print = this.print || console.log;
  18. let arrDylg=+gets();
  19. let arr = gets().split(' ').map(Number);
  20. let count = 0;
  21. for (let i = 0; i < arrDylg; i++) {
  22. if (i==0&& arr[i]>arr[i+1]) {
  23. count=count+1
  24. }else if (arr[i]>arr[i-1]&& arr[i]>arr[i+1]) {
  25. count=count +1;
  26. }
  27.  
  28. }
  29. print(count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement