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 = [
- 12, 5, 2, 3, 4, 5, 5, 5, 5, 6, 7, 6, 7
- ];
- 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());
- }
- //print(arr);
- var currentLength = 1;
- var maxLength = 1;
- var currentElement = arr[0];
- for (var index = 0; index < arr.length; index++) {
- if (arr[index] === currentElement) {
- currentLength +=1;
- if (currentLength > maxLength) {
- maxLength = currentLength;
- }
- } else {
- currentElement = arr[index];
- currentLength = 1;
- }
- }
- print(maxLength);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement