Green and Red

 class Solution {

    static int RedOrGreen(int N, String S) {
        int Red = 0, Green = 0;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'R')
                Red++;
            else
                Green++;
        }
        return Math.min(Red, Green);
    }
}

Comments

Popular posts from this blog

Git and Github

bubble short Q1

Java Program to Check Whether the String Consists of Special Characters