feat(mostRepeatedChar): algoritmo concluido
This commit is contained in:
parent
d66c42f762
commit
6065ccf64c
@ -1,4 +1,17 @@
|
||||
export function mostUsedChar(text) {
|
||||
// implementar logica aqui
|
||||
return ""
|
||||
}
|
||||
var textCounts = {}
|
||||
var maxKey = ''
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var key = text[i]
|
||||
if (!textCounts[key]) {
|
||||
textCounts[key] = 0
|
||||
}
|
||||
textCounts[key]++
|
||||
if (maxKey === '' || textCounts[key] > textCounts[maxKey]) {
|
||||
maxKey = key
|
||||
}
|
||||
}
|
||||
|
||||
return maxKey
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user