Good Array Bob doesn't like character arrays having same consecutive character, so he calls them bad arrays. A good array is the one which does not have any same consecutive letters. You are given a character array, make it a good array. The only allowed operation is: If there are two same consecutive letters, delete one of them. INPUT The first line contains an integer T, denoting the number of test cases. Each test case contain an character array. OUTPUT For each test case, print the answer to the given problem. CONSTRAINTS 1 <= T <= 10 1 <= length of character array <= 10^5 Character array consists of only lower case letters Sample Input
3
abb
aaab
Sample Output
ab
ab
ababa
function main(iterable){
if(iterable.length == 1){
return ''
}
var unique = []
for(var i=0; i< iterable.length; i++){
if(unique.length < 1){
unique.push(iterable[i])
} else if(iterable[i] !== unique[unique.length - 1]) {
unique.push(iterable[i])
}
}
return unique.join('')
}
console.log(main('3'))
console.log(main('aaab'))
console.log(main('abab'))