Competitive Programming Solutions

GitHub
back to dashboard

C. Compare

Codeforces - Sheet #4 (Strings) · limit: 1s · memory: 256MB · view on codeforces

input

acm
acpc

output

acm
Main.java
static void solve() {

        // Write your solution here
        String x = in.next();
        String y = in.next();
        for(int i = 0; i < Math.min(x.length(), y.length()); i++){
            if(x.charAt(i) < y.charAt(i)){
                out.println(x);
                return;
            }
            else if(x.charAt(i) > y.charAt(i)){
                out.println(y);
                return;
            }
        }
        out.println(x.length() < y.length() ? x : y); 

    }