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
- 동적라이브러리
- path planning
- 공유라이브러리
- solver
- Leetcode
- Frenet Coordinate
- OSQP
- GNN
- 선형대수
- 백준
- Recursion
- GIT
- MDP
- autonomous vehicle
- C++
- Hybrid A star
- self driving car
- DynamicProgramming
- Dubins Path
- 정적라이브러리
- 소프티어
- 경로생성
- 수치최적화
- CUDA
- C
- PathPlanning
- Graph Neural Network
- 강화학습
- Motion Planning
- CPP
Archives
- Today
- Total
Swimmer
[LeetCode] 1614. Maximum Nesting Depth of the Parenthesesm, C 본문
Solution
- Simple Count of Max Depth
Time Complexity
O(n)
Space Complexity
O(n)
int maxDpeth(char* s);
int main()
{
char string[] = "(1)+((2))+(((3)))";
int RetVal;
RetVal = maxDpeth(string);
return 0;
}
int maxDpeth(char* s)
{
int Depth = 0;
int MaxDepth = 0;
int NumOfChar = 0;
while (s[NumOfChar] != '\0')
{
if (s[NumOfChar] == '(')
{
++Depth;
}
else if (s[NumOfChar] == ')')
{
--Depth;
}
else
{
// Do Nothing
}
if (Depth > MaxDepth)
{
MaxDepth = Depth;
}
else
{
// Do Nothing
}
++NumOfChar;
}
return MaxDepth;
}
'코딩 문제' 카테고리의 다른 글
[LeetCode] 1880. Check if Word Equals Summation of Two Words, C (0) | 2023.01.05 |
---|---|
[LeetCode] 2406. Divide Intervals Into Minimum Number of Groups, C (0) | 2023.01.02 |
[LeetCode] 2283. Check if Number Has Equal Digit Count and Digit Value, 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 |
Comments