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
- Recursion
- solver
- Dubins Path
- DynamicProgramming
- CPP
- C++
- Graph Neural Network
- 경로생성
- MDP
- CUDA
- OSQP
- 백준
- self driving car
- GIT
- Frenet Coordinate
- 수치최적화
- Leetcode
- Motion Planning
- 공유라이브러리
- autonomous vehicle
- GNN
- Hybrid A star
- PathPlanning
- 소프티어
- 강화학습
- 선형대수
- 동적라이브러리
- C
- 정적라이브러리
- path planning
Archives
- Today
- Total
Swimmer
[LeetCode] 1. Two Sum 본문
Solution
- Brute Force
- Time Complexity : O(N^2)
- Space Omplexity : O(1)
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> RetVal;
for (int i = 0; i != nums.size(); ++i)
{
for (int j = i + 1; j != nums.size(); ++j)
{
if ((nums[i] + nums[j]) == target)
{
RetVal.push_back(i);
RetVal.push_back(j);
return RetVal;
}
}
}
RetVal.push_back(-1);
RetVal.push_back(-1);
return RetVal;
}
};
'개념공부 > C, C++' 카테고리의 다른 글
[C++ STL] unordered_map (0) | 2023.01.16 |
---|---|
[C++ STL] map (0) | 2023.01.16 |
[LeetCode] 1030. Matrix Cells in Distance Order, C++ (0) | 2023.01.09 |
[C++] Unordered Map (작성 중) (0) | 2023.01.08 |
[C++] vector container (0) | 2023.01.06 |
Comments