Solución
solution.tsTypeScript
import java.util.*;
public class Solution {
public Map<Integer, List<String>> groupByLength(String[] words) {
HashMap<Integer, List<String>> groups = new HashMap<>();
for (String word : words) {
int length = word.length();
if (!groups.containsKey(length)) {
groups.put(length, new ArrayList<String>());
}
groups.get(length).add(word);
}
return groups;
}
}0respuestas