Published:
Updated:

https://codeforces.com/problemset/problem/59/A


Solution

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solution {
    public static String returnUpperOrLower(String input) {
        // upper num == lower num -> to lower
        // upper num != lower num -> to upper
        int countIsUpper = 0;
        for (int i = 0; i < input.length(); i++) {
            if (Character.isUpperCase(input.charAt(i))) {
                countIsUpper++;
            }
        }
        // Final
        if (countIsUpper <= input.length() - countIsUpper) { // countIsLower == input.length() - countIsUpper
            return input.toLowerCase();
        } else {
            return input.toUpperCase();
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        System.out.print(returnUpperOrLower(input));
        br.close();
    }
}

Leave a comment