本文介绍: You are given a string consisting of characters which are either or .A move is defined as selecting three consecutive characters of and converting them to . Note that if a move is applied to the character , it will stay the same.Return the minimum numb

Question:

You are given a string s consisting of n characters which are either 'X' or 'O'.

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.

Return the minimum number of moves required so that all the characters of s are converted to 'O'.

Example 1:

Input: s = "XXX"
Output: 1
Explanation: XXX -> OOO
We select all the 3 characters and convert them in one move.

Example 2:

Input: s = "XXOX"
Output:</

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注