Minimum Moves to Convert String LeetCode solution in JavaScript
1var minimumMoves = function (s) {2let move = 0;3let i = 0;4while (i < s.length) {5let char = s[i];6// incrementing the index if we already have 'O'7if (char == "O") {8i++;9}10// incrementing the move and index by 3 (Per move = 3 characters)11if (char == "X") {12i = i + 3;13move++;14}15}16return move;17};