[Java] O(N) + Easy to understand + Important point
The important thing that you might be missing in your solution is that you might be counting 3 letter groups, which won\'t give you the correct answer.\n\nWhy?\
The important thing that you might be missing in your solution is that you might be counting 3 letter groups, which won\'t give you the correct answer.\n\nWhy?\n\nThe reason for this is a test case like this:\n```\n"XXXOXXOXOXO"\n```\n\nSo, if you\'re counting letter groups of 3 at a time, you will count 1 for the first group `XXX` and then you will count 2 for `OXX` and then 3 for `OXO` and 4 for `XO`.\n\nBut this is not the minimum count, which in this case would be 3. \n\nHow?\nYou should count 1 for `XXX` and then 2 for `XXO` (skip `O` in between) and then 3 for `XOX`.\n\nBasically, you should not be counting the `O`s which can be skipped.\n\nNow that you know why this won\'t work, you might also get to the part that you should only increment your count when dealing with an `X`.\n\nSo a simple greedy approach would be something like this:\n\n```\nclass Solution {\n    public int minimumMoves(String s) {\n        int count = 0;\n        \n        for (int i = 0; i < s.length();) {            \n            if (s.charAt(i) == \'X\') {\n                count++;\n                i += 3;\n            } else {\n                i++;\n            }\n        }\n        \n        return count;\n    }\n}\n```\n\nThe greedy approach is that if we find an `X` we count a step immediately and skip over 3 (irrespective of `X` or `O` since we can deal it all in one step).\n\nHope it helps!
['Greedy', 'Java']