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
- dynamic programming
- Binary Search
- sorting
- 코테
- 코딩테스트
- Class
- Matrix
- Counting
- string
- Method
- implement
- greedy
- java
- 파이썬
- simulation
- Math
- Binary Tree
- bit manipulation
- two pointers
- database
- geometry
- Data Structure
- SQL
- Stack
- 자바
- array
- Tree
- Number Theory
- hash table
- 구현
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 771. Jewels and Stones 본문
1. Input
1) 문자열 jewels
2) 문자열 stones
2. Output
1) stones에 담긴 jewel의 개수
2) jewel은 jewels에 담긴 문자 1개를 말한다.
3. Constraint
1) 1 <= jewels.length, stones.length <= 50
2) jewels와 stones는 영어 대소문자로만 이루어져 있다.
3) jewels에는 중복 문자가 없다.
4. Example
Input: jewels = "aA", stones = "aAAbbbb" -> Output: 3
설명: stones에는 “a”나 “A”가 3개가 들어있다.
5. Code
1) 첫 코드(2022/06/12)
int count = 0;
String j = "[" + jewels + "]";
for(int i=0 ; i<stones.length() ; i++){
if( (stones.charAt(i)+"").matches(j) )
count++;
}
return count;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 804. Unique Morse Code Words (0) | 2022.12.07 |
---|---|
[LeetCode/Easy] 796. Rotate String (0) | 2022.12.07 |
[LeetCode/Easy] 762. Prime Number of Set Bits in Binary Representation (0) | 2022.12.07 |
[LeetCode/Easy] 747. Largest Number At Least Twice of Others (0) | 2022.12.07 |
[LeetCode/Easy] 744. Find Smallest Letter Greater Than Target (0) | 2022.12.06 |