File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2027. Minimum Moves to Convert String
3
+ * https://leetcode.com/problems/minimum-moves-to-convert-string/
4
+ * Difficulty: Easy
5
+ *
6
+ * You are given a string s consisting of n characters which are either 'X' or 'O'.
7
+ *
8
+ * A move is defined as selecting three consecutive characters of s and converting them
9
+ * to 'O'. Note that if a move is applied to the character 'O', it will stay the same.
10
+ *
11
+ * Return the minimum number of moves required so that all the characters of s are
12
+ * converted ]to 'O'.
13
+ */
14
+
15
+ /**
16
+ * @param {string } s
17
+ * @return {number }
18
+ */
19
+ var minimumMoves = function ( s ) {
20
+ return s . match ( / X .{ 0 , 2 } / g) ?. length ?? 0 ;
21
+ } ;
Original file line number Diff line number Diff line change 277
277
2000|[ Reverse Prefix of Word] ( ./2000-reverse-prefix-of-word.js ) |Easy|
278
278
2011|[ Final Value of Variable After Performing Operations] ( ./2011-final-value-of-variable-after-performing-operations.js ) |Easy|
279
279
2016|[ Maximum Difference Between Increasing Elements] ( ./2016-maximum-difference-between-increasing-elements.js ) |Easy|
280
+ 2027|[ Minimum Moves to Convert String] ( ./2027-minimum-moves-to-convert-string.js ) |Easy|
280
281
2047|[ Number of Valid Words in a Sentence] ( ./2047-number-of-valid-words-in-a-sentence.js ) |Easy|
281
282
2053|[ Kth Distinct String in an Array] ( ./2053-kth-distinct-string-in-an-array.js ) |Medium|
282
283
2085|[ Count Common Words With One Occurrence] ( ./2085-count-common-words-with-one-occurrence.js ) |Easy|
You can’t perform that action at this time.
0 commit comments