Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md

This file was deleted.

24 changes: 24 additions & 0 deletions arrays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Arrays

+ [Two Sum](#two-sum)

## Two sum

https://leetcode.com/problems/two-sum/

```python
class Solution(object):
def twoSum(self, nums, target):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А теперь рядом решение, где ты сначала сортируешь числа, а потом с помощью двух указателей left, right находишь нужный target.

Ты эти два указателя с краев сдвигаешь к центру и постоянно проверяешь, найден ли target

"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""

indices = {}
for index in range(len(nums)):
if target - nums[index] in indices:
return [indices[target - nums[index]], index]
indices[nums[index]] = index

```