Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- let print = [];
- for(let i = 0; i < arr.length; i++) {
- let current = [];
- for(let j = ++i; j < arr.length; j++) {
- if (arr[i] === arr[j]){
- current.push(arr[i]);
- } else {
- i = ++j;
- break;
- }
- }
- current.length > print.length ? print = current : print;
- }
- console.log(print.join(" "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement