I'm a new student here, sorry to ask a simple question, and I'm trying to solve a problem in order to count the same letter.
Input:"aabbcde"
cause a = 2, b= 2, c= 1 , d =1 , e = 1
Output:"2a2b1c1d1e" or a2b2c1d1e1
and here my code is not finished i'm stuck
function repeatL(str) {
var word = str.split("").sort();
var temp = 0;
var i =1;
while(i< word.length){
if(word[i] === word[i +1]) {
};
}
}
repeatL("abbbdd");
also, if the input is not a string, but an array:
Input:[a,ab,bc,d,e]
what can even be solved?
source
share