Minimum Moves to Convert String Problem
Minimum Moves to Convert String Problem — ExecCode Easy DSA Practice
Solve the Minimum Moves to Convert String problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a string s consisting of n characters which are either 'X' or 'O'. Your task is to compute the required answer and return the minimum number of moves required so that all the characters of s are converted to 'O'. A move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.
Examples
Input {"s": "XXX"}; Output 1. Input {"s": "XXOX"}; Output 2
Constraints
3 <= s.length <= 1000 s[i] is either 'X' or 'O'.
Practice Minimum Moves to Convert String free on ExecCode. Browse DSA problems, topic map, and placement guides.