Skip to content

Commit f933fad

Browse files
committed
Coding solutions uploaded.
1 parent 12c6aba commit f933fad

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

coding_solutions/Readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Coding Python solutions
2+
## About
3+
This repository contains my answers to all Leetcode/HackerRank algorithm questions. This problems are largely made up of actual interview questions from huge companies such as Facebook, Amazon, Netflix, and Google. If you find my solutions difficult to understand, take some time to tackle simpler issues or visit the problem discussion section on LeetCode. Feel free to connect me if you have any suggestions for changes.
4+
5+
## List of Problems
6+
| # | Problem | Solution |
7+
| :----: | :-----------------------------: | :----: |
8+
| 1 | [Two Sum](https://leetcode.com/problems/two-sum/)| [python3]() |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def twoSum(self, nums: List[int], target: int) -> List[int]:
3+
record = {}
4+
for i in range(len(nums)):
5+
curnum = nums[i]
6+
diff = target - curnum
7+
if diff not in record:
8+
record[curnum] = i
9+
elif diff in record:
10+
return [record[diff], i]
11+
12+
return []

0 commit comments

Comments
 (0)