Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = ['aaabbbccccCCCCC'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let arr = gets().split('');
- let tempCount = 1;
- let totCount = 1;
- let currentSymb = arr[0];
- let longest = currentSymb;
- for (let i = 0; i <= arr.length; i++) {
- if (arr[i] === arr[i - 1]) {
- tempCount++;
- currentSymb += arr[i];
- } else {
- if (tempCount > totCount) {
- totCount = tempCount;
- longest = currentSymb
- } tempCount = 1;
- currentSymb = arr[i];
- }
- }
- console.log(longest)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement