Advertisement
bai_onzi

Untitled

Feb 19th, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = ['10', '2', '1', '1', '2', '3', '3', '2', '2', '2', '1'];
  2.  
  3.  
  4. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  5.  
  6. let arrLength = +gets();
  7. let arr = [];
  8. let maxEquals=1;
  9. let currentEquals=1;
  10.  
  11. for(let i = 1; i <= arrLength; i++){
  12.     let arrNums = gets();
  13.     arr.push(parseInt(arrNums));
  14.     if(arr[i] === arr[i-1]){
  15.         currentEquals + 1;
  16.         if(currentEquals > maxEquals){
  17.             maxEquals = currentEquals;
  18.         }
  19.     }else{
  20.         currentEquals = 1;
  21.     }
  22.     // console.log(maxEquals);
  23. }
  24. // console.log(arr)
  25. console.log(maxEquals);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement