Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = ['10', ['2', '1', '1', '2', '3', '3', '2', '2', '2', '1']];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- const n = +gets();
- const arr = gets();
- let startingIndex = 0;
- let count;
- let finalIndex = 0;
- let maxCount = 0;
- for(let i = 0; i < n; i++) {
- startingIndex = i;
- count = 0;
- let elToCompare = Number(arr[i]);
- for(let j = i; j < n; j++) {
- let el = Number(arr[j]);
- if(el === elToCompare) {
- count++;
- } else {
- break;
- }
- }
- if(count > maxCount) {
- maxCount = count;
- finalIndex = startingIndex;
- }
- }
- let result = arr.splice(finalIndex, maxCount);
- print(result.length);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement