✅ Short & Self Explanatory | 3 Approaches | C++ | Beginner friendly
1.recursion\n\nclass Solution {\npublic:\n    int minimumMoves(string s,int index=0) {\n        if(index >= s.size()){\n            return 0;\n        }\n      
**1.recursion**\n```\nclass Solution {\npublic:\n    int minimumMoves(string s,int index=0) {\n        if(index >= s.size()){\n            return 0;\n        }\n        \n        if(s[index] == \'X\'){\n            return minimumMoves(s,index+3)+1;\n        }else{\n            return minimumMoves(s,index+1);\n        }\n    }\n};\n```\n**2.traversing the complete string**\n```\nclass Solution {\npublic:\n    int minimumMoves(string s) {\n        int moves = 0;\n        s += "OO";\n        for(int i = 0; i < s.size(); i++) {\n            if(s[i] == \'X\') {\n                s[i] = s[i + 1] = s[i + 2] = \'O\';\n                moves++;\n            }\n        }\n        return moves;\n    }\n};\n```\n**3.**\n```\nclass Solution {\npublic:\n    int minimumMoves(string s) {\n        int moves=0;\n        for(int i=0;i<s.length();){\n            if(s[i]==\'X\'){\n                i+=3,moves++;\n            }else{\n                i++;\n            }\n        }\n        return moves;\n    }\n};\n```\n**Feel free to ask any question in the comment section.**\nI hope that you\'ve found the solution useful.\nIn that case, **please do upvote and encourage me** to on my quest to document all leetcode problems\uD83D\uDE03\nHappy Coding :)\n
['C', 'C++']