Skip to content

Commit 3442fa9

Browse files
committed
[ADD] LeetCode TwoSum
1 parent d2aa948 commit 3442fa9

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

LeetCode/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[LeetCode](https://leetcode.com/problemset/all)
2+
-----------------------------------------------
3+
4+
<details open> <summary> 접기 / 펼치기 </summary>
5+
6+
| 번호 | 문제 | 코드 | 번호 | 문제 | 코드 |
7+
|:----:|:-----------------------------------------------:|:------------------------:|:----:|:----:|:----:|
8+
| 1 | [TwoSum](https://leetcode.com/problems/two-sum) | [cpp](source/TwoSum.cpp) | | | |
9+
10+
</details>

LeetCode/source/TwoSum.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// TwoSum
2+
// 2021.10.21
3+
// Easy
4+
class Solution
5+
{
6+
public:
7+
vector<int> twoSum(vector<int>& nums, int target)
8+
{
9+
unordered_map<int, int> maps;
10+
for (int i = 0; i < nums.size(); i++)
11+
{
12+
if (maps.find(target - nums[i]) != maps.end())
13+
{
14+
return { maps[target - nums[i]], i };
15+
}
16+
else
17+
{
18+
maps[nums[i]] = i;
19+
}
20+
}
21+
return {};
22+
}
23+
};

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
알고리즘 문제풀이
22
=================
33

4-
- [백준 온라인저지](https://www.acmicpc.net), [프로그래머스](https://programmers.co.kr/), [HackerRank](https://www.hackerrank.com), [swexpertacademy](http://swexpertacademy.com), [codility](https://app.codility.com/programmers), [goorm](https://level.goorm.io) 사이트의 알고리즘 문제 풀이입니다.
4+
- [백준 온라인저지](https://www.acmicpc.net), [프로그래머스](https://programmers.co.kr/), [HackerRank](https://www.hackerrank.com), [swexpertacademy](http://swexpertacademy.com), [codility](https://app.codility.com/programmers), [goorm](https://level.goorm.io), [LeetCode](https://leetcode.com/problemset/all) 사이트의 알고리즘 문제 풀이입니다.
55
- 주로 `C++`로 풀었고 `Java`로 푼 문제가 조금 있습니다.
66
- 아래 사이트 이름을 클릭하면 해당 사이트의 문제풀이를 진행한 위치로 이동합니다.
77
- 이동한 위치에는 `README.md` 파일로 풀었던 문제들이 표로 나열되어 있습니다.
88

9-
### 1. [백준 온라인 저지](https://github.com/tdm1223/Algorithm/tree/master/acmicpc.net)
9+
### 1. [백준 온라인 저지](acmicpc.net)
1010

11-
### 2. [프로그래머스](https://github.com/tdm1223/Algorithm/tree/master/programmers)
11+
### 2. [프로그래머스](programmers)
1212

13-
### 3. [HackerRank](https://github.com/tdm1223/Algorithm/tree/master/hackerrank.com)
13+
### 3. [HackerRank](hackerrank.com)
1414

15-
### 4. [SW Expert Academy](https://github.com/tdm1223/Algorithm/tree/master/swexpertacademy.com)
15+
### 4. [SW Expert Academy](swexpertacademy.com)
1616

17-
### 5. [Codility](https://github.com/tdm1223/Algorithm/tree/master/codility)
17+
### 5. [Codility](codility)
1818

19-
### 6. [goorm](https://github.com/tdm1223/Algorithm/tree/master/goorm.io)
19+
### 6. [goorm](goorm.io)
20+
21+
### 7. [LeetCode](LeetCode)

0 commit comments

Comments
 (0)