• 문제 링크
Jewels and Stones - LeetCode
Can you solve this real interview question? Jewels and Stones - You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to kno
leetcode.com
• 풀이 코드
public class Solution {
public int numJewelsInStones(String jewels, String stones) {
boolean[] arr = new boolean[128];
for (char c : jewels.toCharArray()) arr[c] = true;
int cnt = 0;
for (char c : stones.toCharArray()) if (arr[c]) cnt++;
return cnt;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 796. Rotate String - Java (0) | 2026.10.15 |
|---|---|
| [LeetCode] 783. Minimum Distance Between BST Nodes - Java (0) | 2026.10.14 |
| [LeetCode] 766. Toeplitz Matrix - Java (0) | 2026.10.12 |
| [LeetCode] 762. Prime Number of Set Bits in Binary Representation - Java (0) | 2026.10.11 |
| [LeetCode] 748. Shortest Completing Word - Java (0) | 2026.10.10 |
댓글