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
- geometry
- two pointers
- Math
- Method
- 코딩테스트
- java
- bit manipulation
- 파이썬
- Number Theory
- Binary Tree
- Matrix
- 코테
- string
- Class
- Stack
- Counting
- Tree
- hash table
- Binary Search
- 자바
- array
- simulation
- implement
- dynamic programming
- SQL
- database
- Data Structure
- sorting
- 구현
- greedy
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1668. Maximum Repeating Substring 본문
1. Input
1) String sequence
2) String word
2. Output
1) word가 sequence에서 반복되는 최대 수를 반환
3. Constraint
1) 1 <= sequence.length <= 100
2) 1 <= word.length <= 100
3) sequence와 word는 영어 소문자로 이루어져 있다.
4. Example
Input: sequence = "ababc", word = "ab" -> Output: 2
Input: sequence = "ababc", word = "ba" -> Output: 1
Input: sequence = "ababc", word = "ac" -> Output: 0
5. Code
1) 첫 코드(2023/06/19)
class Solution {
public int maxRepeating(String sequence, String word) {
int ans = 0, rep = sequence.length()/word.length();
while(rep>0){
if(sequence.contains((word.repeat(rep)))){
ans = rep; break;
}
rep--;
}
return ans;
}
}
- 91%, 60%
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[백준 온라인 저지] 1516. 게임 개발 (0) | 2023.06.19 |
---|---|
[LeetCode/Easy] 1758. Minimum Changes To Make Alternating Binary String (0) | 2023.06.19 |
[백준 온라인 저지] 2252. 줄 세우기 (0) | 2023.06.14 |
[LeetCode/Easy] 1629. Slowest Key (0) | 2023.06.13 |
[LeetCode/Easy] 1496. Path Crossing (0) | 2023.06.13 |