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 = [
- 6, -26, -25, -28, 31, 2, 27
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- // code
- const n = +gets();
- const arr = new Array();
- for(let i = 0; i < n; i++) {
- arr.push(gets());
- }
- var result = -1;
- for (var index = 0; index < arr.length - 1; index++) {
- if((index == 0) || (index == arr.length - 1)){
- continue;
- }else{
- if ((arr[index - 1] < arr[index]) && (arr[index] > arr[index + 1])){
- result = index;
- break;
- }
- }
- }
- print(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement