All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2001_2100.s2027_minimum_moves_to_convert_string.Solution Maven / Gradle / Ivy

There is a newer version: 1.24
Show newest version
package g2001_2100.s2027_minimum_moves_to_convert_string;

// #Easy #String #Greedy #2022_05_25_Time_0_ms_(100.00%)_Space_40_MB_(97.32%)

public class Solution {
    public int minimumMoves(String s) {
        int r = 0;
        int i = 0;
        char[] sArray = s.toCharArray();
        while (i < sArray.length) {
            if (sArray[i] == 'X') {
                r++;
                i += 2;
            }
            i++;
        }
        return r;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy