Skip to content

Commit 0b97fe8

Browse files
Alimov-8Alimov-8
authored andcommitted
141
1 parent 1620d53 commit 0b97fe8

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Leetcode 141. Linked List Cycle
2+
3+
4+
## HashTable and Loop
5+
```py
6+
7+
# Definition for singly-linked list.
8+
# class ListNode:
9+
# def __init__(self, x):
10+
# self.val = x
11+
# self.next = None
12+
13+
class Solution:
14+
def hasCycle(self, head: Optional[ListNode]) -> bool:
15+
d = {}
16+
17+
while(True):
18+
if head is None:
19+
return False
20+
21+
if head.next in d.keys():
22+
if head.val == d[head.next]:
23+
return True
24+
25+
d[head.next] = head.val
26+
head = head.next
27+
28+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Leetcode 21. Merge Two Sorted Lists
2+
3+
4+
## LinkedList Looping
5+
```py
6+
# Time Complexity -
7+
8+
```
9+
10+
11+
12+
13+

Data Structure 1/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
# LeetCode Study Plan 📋 | [Data Structures 1](https://leetcode.com/study-plan/data-structure/)
22

33
## Solutions
4-
Array
4+
55
- [1. Two Sum - Brute Force and Dictionary](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/1.%20Two%20Sum.md#leetcode-1-two-sum)
66

7-
- [36. Valid Sudoku](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/36.%20Valid%20Sudoku.md#list-comprehensions-sets-count)
7+
- [36. Valid Sudoku - Array](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/36.%20Valid%20Sudoku.md#list-comprehensions-sets-count)
88

99
- [53. Max Sub Array - Kadane's Algorithm](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/53.%20Maximum%20Subarray.md#leetcode-53-max-sub-array)
1010

1111
- [83. Remove Duplicates from Sorted List - Recursion](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/)
1212

1313
- [88. Merge Sorted Array - Two Pointers, Compersion Sorting](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/88.%20Merge%20Sorted%20Array.md#leetcode-88-merge-sorted-array)
1414

15-
- [118. Pascal's Triangle](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/118.%20Pascal's%20Triangle.md#leetcode-118-pascals-triangle)
15+
- [118. Pascal's Triangle - Array](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/118.%20Pascal's%20Triangle.md#leetcode-118-pascals-triangle)
1616

1717
- [121. Best Time to Buy and Sell Stock](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/121.%20Best%20Time%20to%20Buy%20and%20Sell%20Stock.md#leetcode-121-best-time-to-buy-and-sell-stock)
1818

19+
- [141. Linked List Cycle - Hashmap, Loop](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/)
20+
21+
1922
- [206. Reverse the LinkedList - Recursion](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/)
2023

2124
- [217. Contains Duplication - Dictionary](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/217.%20Contains%20Duplicate.md#leetcode-217-contains-duplication)
2225

2326
- [350. Intersection of Two Arrays II - Dictionary, Loops](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/217.%20Contains%20Duplicate.md#leetcode-350-intersection-of-two-array-ii)
2427

25-
- [383. Ransom Note](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/383.%20Ransom%20Note.md)
28+
- [383. Ransom Note - HashMap, Counting](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/383.%20Ransom%20Note.md)
2629

2730
- [387. First Unique Character in a String](https://github.com/Alimov-8/leetcode-solutions/blob/master/Data%20Structure%201/387.%20First%20Unique%20Character%20in%20a%20String.md#leetcode-387-first-unique-character-in-a-string)
2831

0 commit comments

Comments
 (0)