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
- Class
- Number Theory
- 코딩테스트
- Tree
- dynamic programming
- Counting
- greedy
- java
- Matrix
- hash table
- simulation
- bit manipulation
- Stack
- 자바
- array
- Binary Search
- SQL
- database
- two pointers
- Math
- Binary Tree
- 파이썬
- implement
- Data Structure
- Method
- string
- 구현
- sorting
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] k의 개수 본문
1. Input
1) 정수 i
2) 정수 j
3) 정수 k
2. Output
1) [i, j] 범위의 모든 수에 대해 k가 몇 번 등장하는지를 반환
3. Constraint
1) 1 ≤ i < j ≤ 100,000
2) 0 ≤ k ≤ 9
4. Example
Input: i=10, j=50, k=5 -> Output: 5
설명: 10부터 50까지 5는 15, 25, 35, 45, 50 총 5번 등장한다.
5. Code
1) 첫 코드(2022/12/27)
String s = "";
for(int a=i ; a<=j ; a++)
s += String.valueOf(a);
return s.replaceAll("[^"+k+"]","").length();
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1614. Maximum Nesting Depth of the Parentheses (0) | 2022.12.29 |
---|---|
[프로그래머스/Lv.1] 과일 장수 (0) | 2022.12.28 |
[프로그래머스/Lv.2] 주식가격 (0) | 2022.12.27 |
[LeetCode/Easy] 1603. Design Parking System (0) | 2022.12.27 |
[LeetCode/Easy] 1572. Matrix Diagonal Sum (0) | 2022.12.27 |