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
- Graph Neural Network
- MDP
- 경로생성
- solver
- GIT
- 선형대수
- PathPlanning
- 강화학습
- Leetcode
- CPP
- DynamicProgramming
- C++
- self driving car
- OSQP
- GNN
- path planning
- Hybrid A star
- 백준
- 수치최적화
- C
- autonomous vehicle
- 소프티어
- Motion Planning
- 공유라이브러리
- CUDA
- Recursion
- 정적라이브러리
- 동적라이브러리
- Dubins Path
- Frenet Coordinate
Archives
- Today
- Total
Swimmer
[LeetCode] 2283. Check if Number Has Equal Digit Count and Digit Value, C 본문
코딩 문제
[LeetCode] 2283. Check if Number Has Equal Digit Count and Digit Value, C
Zach Choi 2023. 1. 1. 10:45Solution
- Use Hash Table
Time Complexity
O(n)
Space Complexity
O(n)
#include <stdbool.h>
bool digitCount(char* pnum);
int main()
{
char string[] = "030";
bool RetVal;
RetVal = digitCount(string);
return 0;
}
bool digitCount(char* pnum)
{
bool bRetVal = true;
const int ASCIINumberInit = 48;
int i = 0;
int NumOfChar = 0;
int arrHashTable[10] = { 0 };
while (pnum[NumOfChar] != '\0')
{
arrHashTable[pnum[NumOfChar] - ASCIINumberInit] += 1;
++NumOfChar;
}
for (i = 0; i != NumOfChar; ++i)
{
if (arrHashTable[i] != (pnum[i] - ASCIINumberInit))
{
bRetVal = false;
break;
}
else
{
// Do Nothing
}
}
return bRetVal;
}
'코딩 문제' 카테고리의 다른 글
[LeetCode] 2406. Divide Intervals Into Minimum Number of Groups, C (0) | 2023.01.02 |
---|---|
[LeetCode] 1614. Maximum Nesting Depth of the Parenthesesm, C (0) | 2023.01.01 |
[LeetCode] 888. Fair Candy Swap, C (0) | 2022.12.31 |
[LeetCode] 1941. Check if All Characters Have Equal Number of Occurrences, C (0) | 2022.12.31 |
[LeetCode] 383. Ransom Note, C (0) | 2022.12.30 |
Comments