Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.LinkedHashMap;
- import java.util.Map;
- public class Veronika {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String line = reader.readLine();
- LinkedHashMap<Character, Integer> symbolCount = countSymbols(line);
- int max = -1;
- char maxCh = 'a';
- for (Map.Entry<Character, Integer> entry : symbolCount.entrySet()) {
- if (entry.getValue() > max) {
- max = entry.getValue();
- maxCh = entry.getKey();
- }
- }
- if (max > 1){
- //TODO CHANGE THE WORD
- }
- }
- private static LinkedHashMap<Character, Integer> countSymbols(String line) {
- LinkedHashMap<Character, Integer> counter = new LinkedHashMap<>();
- for (char ch : line.toCharArray()) {
- if (counter.containsKey(ch)) {
- counter.put(ch, counter.get(ch) + 1);
- } else {
- counter.put(ch, 1);
- }
- }
- return counter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement