Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Stack
- java
- 파이썬
- 구현
- 코딩테스트
- Binary Search
- Matrix
- simulation
- SQL
- Class
- sorting
- bit manipulation
- implement
- Math
- 자바
- Binary Tree
- Method
- array
- Tree
- database
- string
- Counting
- greedy
- Data Structure
- two pointers
- dynamic programming
- hash table
- Number Theory
- 코테
- geometry
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2027. Minimum Moves to Convert String 본문
1. Input
1) String s
2. Output
1) s의 모든 문자를 'O'로 바꾸는 최소 횟수를 반환
- 한번에 연속된 3개의 문자를 O로 바꿀 수 있다.
- O는 그대로 O이다.
3. Constraint
1) 3 <= s.length <= 1000
2) s는 O 또는 X로 이루어진 문자열이다.
4. Example
Input: s = "XXOX" -> Output: 2
설명: XXOX -> OOOX -> OOOO
5. Code
1) 첫 코드(2023/04/26)
class Solution {
public int minimumMoves(String s) {
int count = 0;
for(int i=0 ; i<s.length() ; i++){
if(s.charAt(i)=='X'){
count++;
i += 2;
}
}
return count;
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2053. Kth Distinct String in an Array (0) | 2023.04.26 |
---|---|
[LeetCode/Easy] 2047. Number of Valid Words in a Sentence (0) | 2023.04.26 |
[프로그래머스/Lv.0] 문자열 여러 번 뒤집기 (0) | 2023.04.25 |
[프로그래머스/Lv.0] 배열 만들기 2 (0) | 2023.04.25 |
[프로그래머스/Lv.0] 홀수 vs 짝수 (0) | 2023.04.25 |