4 ms·
No java ! here is my code golf version var map = new BufferedReader(new InputStreamReader(in, UTF_8)) .lines() .flatMap(compile(" "
by _old_dude_ 6y ago
No java ! here is my code golf version
var map =
new BufferedReader(new InputStreamReader(in, UTF_8))
.lines()
.flatMap(compile(" ")::splitAsStream)
.collect(groupingBy(w -> w, () -> new TreeMap<>(reverseOrder()), counting()));
It obviously doesn't work without the imports
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeMap;
import static java.lang.System.in;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Collections.reverseOrder;
import static java.util.regex.Pattern.compile;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
- killingtime74 6y agoMaybe graalvm native version could be competitive