Data Structures and Algorithms in Python
https://leetcode.com/problemsets/all/
| array_hashing | ||
| binary_search | ||
| linked_list | ||
| sliding_window | ||
| stack | ||
| two_pointers | ||
| .gitignore | ||
| README.md | ||
Data Structures and Algorithms in Python (LeetCode)
This repository contains all data structures and algorithms from LeetCode written in Python.
- Author: Sakthi Santhosh
- Created on: 24/07/2023
Links
- Data Structures and Algorithms in C: GitHub (sakthisanthosh010303/c)
- First 150 Programs List: NeetCode
Metrics
Programs Solved
- Total: 44
- Easy: 10
- Medium: 29
- Hard: 5
Programs List
| ID | Program | Type | Difficulty | Time Complexity | Space Complexity |
|---|---|---|---|---|---|
| 217 | Contains Duplicate | Array and Hashing | Easy | O(N) | O(N) |
| 242 | Valid Anagram | Array and Hashing | Easy | O(2N) → O(N) | O(2N) → O(N) |
| 1 | Two Sum | Array and Hashing | Easy | O(N) | O(N) |
| 49 | Group Anagrams | Array and Hashing | Medium | O(M * N) | O(M * N) |
| 347 | Top K Frequent Elements | Array and Hashing | Medium | O(2N) → O(N) | O(2N) → O(N) |
| 238 | Product of Array Except Self | Array and Hashing | Medium | O(2N) → O(N) | O(1) |
| 36 | Valid Sudoku | Array and Hashing | Medium | O(N) | O(3N) → O(N) |
| 128 | Longest Common Sequence | Array and Hashing | Medium | O(N) | O(1) |
| 125 | Valid Palindrome | Two Pointers | Easy | O(N) | O(1) |
| 167 | Two Sum II - Input Array is Sorted | Two Pointers | Medium | O(N) | O(1) |
| 15 | 3Sum | Two Pointers | Medium | O(N^2) | O(1) or O(N) |
| 15 | 3Sum Closest | Two Pointers | Medium | O(N^2) | O(1) or O(N) |
| 11 | Container with Most Water | Two Pointers | Medium | O(N) | O(1) |
| 42 | Trapping Rain Water | Two Pointers | Hard | O(N) | O(1) |
| 121 | Best Time to Buy and Sell Stocks | Sliding Window | Easy | O(N) | O(1) |
| 424 | Longest Repeating Character Replacement | Sliding Window | Medium | O(N) | O(N) |
| 3 | Longest Substring without Repeating Characters | Sliding Window | Medium | O(N) | O(N) |
| 567 | Permutation in String | Sliding Window | Medium | O(N) | O(1) |
| 76 | Minimum Window Substring | Sliding Window | Hard | O(N) | O(N) |
| 239 | Sliding Window Maximum | Sliding Window | Hard | O(N) | O(N) |
| 209 | Minimum Size Subarray Sum | Sliding Window | Medium | O(N) | O(1) |
| 20 | Valid Parentheses | Stack | Easy | O(N) | O(N) |
| 155 | Min Stack | Stack | Medium | O(1) | O(2N) → O(N) |
| 150 | Evaluate Reverse Polish Notation | Stack | Medium | O(N) | O(N) |
| 22 | Generate Parentheses | Stack | Medium | - | O(N) |
| 739 | Daily Temperatures | Stack | Medium | O(N) | O(N) |
| 853 | Car Fleet | Stack | Medium | O(N) | O(N) |
| 84 | Largest Rectangle in Histogram | Stack | Hard | O(N) | O(N) |
| 704 | Binary Search | Binary Search | Easy | O(LOG(N)) | O(1) |
| 74 | Search a 2D Matrix | Binary Search | Medium | O(LOG(M * N)) | O(1) |
| 875 | Koko Eating Bananas | Binary Search | Medium | O(N * LOG(P)) | O(1) |
| 153 | Find Minimum in Rotated Sorted Array | Binary Search | Medium | O(LOG(N)) | O(1) |
| 33 | Search in Rotated Sorted Array | Binary Search | Medium | O(LOG(N)) | O(1) |
| 981 | Time Based Key-value Store | Binary Search | Medium | O(LOG(N)) | O(1) |
| 153 | Median of Two Sorted Arrays | Binary Search | Hard | O(LOG(MIN(M, N))) | O(1) |
| 206 | Reverse Linked List | Linked List | Easy | O(N) | O(1) |
| 21 | Merge Two Sorted Lists | Linked List | Easy | O(N + M) → O(N) | O(1) |
| 143 | Reorder List | Linked List | Medium | O(N) | O(1) |
| 19 | Remove Nth Node from End of List | Linked List | Medium | O(N) | O(1) |
| 138 | Copy List with Random Pointer | Linked List | Medium | O(N) | O(N) |
| 2 | Add Two Numbers | Linked List | Medium | O(M + N) | O(M + N) |
| 141 | Linked List Cycle | Linked List | Easy | O(N) | O(1) |
| 287 | Find the Duplicate Number | Linked List | Medium | O(N) | O(1) |
| 146 | LRU Cache | Linked List | Medium | O(1) | O(N) |