Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = [
- '7',
- '-26 -25 -28 31 2 27 5',
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- let arrDylg=+gets();
- let arr = gets().split(' ').map(Number);
- let count = 0;
- for (let i = 0; i < arrDylg; i++) {
- if (i==0&& arr[i]>arr[i+1]) {
- count=count+1
- }else if (arr[i]>arr[i-1]&& arr[i]>arr[i+1]) {
- count=count +1;
- }
- }
- print(count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement