Files
obsidian/АиСД/Задачи/LeetCode/Jewels and Stones.md
T
roma-dxunvrs 0e6e583e6d
deploy / Pull and Restart (push) Successful in 17s
refactor: wiki links -> md links
2026-09-22 08:52:23 +03:00

18 lines
516 B
Markdown

Leetcode #771 | #Easy | [Хэш-таблицы](../../Структуры/Хэш-таблицы.md)
## Идея
Просто set
## Big-O
- Время ```O(N+M)```
- Память ```O(N)```
## Код
```Java
class Solution {
public int numJewelsInStones(String jewels, String stones) {
Set<Character> set = new HashSet<>();
for (char c : jewels.toCharArray()) set.add(c);
int res = 0;
for (char c : stones.toCharArray()) if (set.contains(c)) res++;
return res;
}
}
```