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 |
Tags
- 동적라이브러리
- 소프티어
- C++
- Recursion
- DynamicProgramming
- path planning
- 강화학습
- C
- PathPlanning
- self driving car
- GNN
- Hybrid A star
- Motion Planning
- 선형대수
- 정적라이브러리
- CPP
- autonomous vehicle
- solver
- CUDA
- 경로생성
- Leetcode
- Graph Neural Network
- MDP
- Dubins Path
- 백준
- Frenet Coordinate
- GIT
- OSQP
- 공유라이브러리
- 수치최적화
Archives
- Today
- Total
Swimmer
[LeetCode] 771, Jewels and Stones 본문
Skill
- Use hash table to decrease time complexity to under log(n^2)
Others
- Use string struct member
- Use ASCII Number of english letter
int gstHashTable[60] = { 0 };
class Solution {
public:
int numJewelsInStones(string jewels, string stones) {
memset(&gstHashTable, 0, sizeof(int) * 60);
int RetVal = 0;
for (int i = 0; i != stones.size(); ++i)
{
gstHashTable[stones[i] - 65]++;
}
for (int i = 0; i != jewels.size(); ++i)
{
RetVal += gstHashTable[jewels[i] - 65];
}
return RetVal;
}
};
'코딩 문제' 카테고리의 다른 글
LeetCode 62. Unique Path (0) | 2023.07.27 |
---|---|
LeetCode 1768 Merge String Alternately (0) | 2023.07.17 |
[LeetCode] 1720 Decode XORred Array (0) | 2023.01.29 |
[LeetCode] 728. Self Dividing Numbers, C++ (0) | 2023.01.26 |
[LeetCode] 2032. Two Out of Three, C++ (0) | 2023.01.25 |
Comments