Skip to content

Latest commit

 

History

History
250 lines (210 loc) · 32.7 KB

README.md

File metadata and controls

250 lines (210 loc) · 32.7 KB

This repository contains my solutions to problems from the Neetcode curated list of coding interview questions. I will be solving these problems primarily in Python.

Repository Structure

Each problem is stored in its own subfolder under the Problem directory. Each subfolder contains a Markdown file with the problem description, my thoughts, and the solution in Python or another language of choice.

Problems

Array and Hashing

Number Problem Leetcode Number/Solution Difficulty
1 Contains Duplicate 217 Easy
2 Valid Anagram 242 Easy
3 Two Sum 1 Easy
4 Group Anagrams 49 Medium
5 Top K Frequent Elements 347 Medium
6 Product of Array Except Self 238 Medium
7 Valid Sudoku 36 Medium
8 String Encode and Decode ??1 Medium
9 Longest Consecutive Sequence 128 Medium

Two Pointers

Number Problem Leetcode Number/Solution Difficulty
1 Valid Palindrome 125 Easy
2 Two Sum II - Input Array Is Sorted 167 Medium
3 3sum 15 Medium
4 Container With Most Water 15 Medium
4 Trapping Rain Water 42 Hard

Sliding Window

Number Problem Leetcode Number/Solution Difficulty
1 Best Time to Buy and Sell Stock 121 Easy
2 Longest Substring Without Repeating Characters 3 Medium
3 Longest Repeating Character Replacement 424 Medium
4 Permutation In String 567 Medium
5 Minimum Window Substring 76 Hard
6 Sliding Window Maximum 239 Hard

Stack

Number Problem Leetcode Number/Solution Difficulty
1 Valid Parentheses 20 Easy
2 Min Stack 155 Medium
3 Evaluate Reverse Polish Notation 150 Medium
4 Generate Parentheses 22 Medium
5 Daily Temperatures 739 Medium
6 Car Fleet 853 Medium
7 Largest Rectangle in Histogram 84 Hard

Binanry Search

Number Problem Leetcode Number/Solution Difficulty
1 Binary Search 704 Easy
2 Search a 2D Matrix 74 Medium
3 Koko Eating Bananas 875 Medium
4 Find Minimum in Rotated Sorted Array 153 Medium
5 Search in Rotated Sorted Array 33 Medium
6 Time Based Key-Value Store 981 Medium
6 Time Based Key-Value Store 981 Medium
7 Median of Two Sorted Arrays 4 Hard

Linked List

Number Problem Leetcode Number/Solution Difficulty
1 Reverse Linked List 206 Easy
2 Merge Two Sorted Lists 21 Easy
3 Reorder List 143 Medium
4 Remove Nth Node From End of List 19 Medium
5 Copy List with Random Pointer 138 Medium
6 Add Two Numbers 2 Medium
7 Linked List Cycle 141 Easy
8 Find the Duplicate Number 287 Medium
9 LRU Cache 146 Medium
10 Merge k Sorted Lists 23 Hard
11 Reverse Nodes in k-Group 25 Hard

Trees

Number Problem Leetcode Number/Solution Difficulty
1 Invert Binary Tree 226 Easy
2 Maximum Depth of Binary Tree 104 Easy
3 Diameter of Binary Tree 543 Easy
4 Balanced Binary Tree 110 Easy
5 Same Tree 100 Easy
6 Subtree of Another Tree 572 Easy
7 Lowest Common Ancestor of a Binary Search Tree 235 Medium
8 Binary Tree Level Order Traversal 102 Medium
9 Binary Tree Right Side View 199 Medium
10 Count Good Nodes in Binary Tree 1448 Medium
11 Validate Binary Search Tree 98 Medium
12 Kth Smallest Element in a BST 230 Medium
13 Construct Binary Tree from Preorder and Inorder Traversal 105 Medium
14 Binary Tree Maximum Path Sum 124 Hard
14 Serialize and Deserialize Binary Tree 297 Hard

Heaps

Number Problem Leetcode Number/Solution Difficulty
1 Kth Largest Element in a Stream 703 Easy
2 Last Stone Weight 1046 Easy
3 K Closest Points to Origin 973 Medium
4 Kth Largest Element in an Array 215 Medium
5 Task Scheduler 621 Medium
6 Design Twitter 355 Medium
7 Find Median from Data Stream 295 Hard

Backtracking

Number Problem Leetcode Number/Solution Difficulty
1 Subsets 78 medium
2 Combination Sum 39 medium
3 Permutations 46 medium
4 Subsets II 90 medium
5 Combination Sum II 40 medium
6 Word Search 79 medium
7 Palindrome Partitioning 131 medium
7 Letter Combinations of a Phone Number 17 medium
8 N-Queens 51 hard

Tries

Number Problem Leetcode Number/Solution Difficulty
1 Implement Trie (Prefix Tree) 208 medium
2 Design Add and Search Words Data Structure 211 medium
3 Word Search II 212 medium

Graphs

Number Problem Leetcode Number/Solution Difficulty
1 Number of Islands 200 medium
2 Clone Graph 133 medium
3 Max Area of Island 695 medium
4 Max Area of Island 417 medium
5 Surrounded Regions 130 medium
6 Rotting ORanges 994 medium
7 Islands and Treasures ??2 medium
8 Course Schedule 207 medium
9 Course Schedule II 210 medium
10 Count Connected Components ??3 medium
11 Redundant Connection 684 medium
12 Graph Valid Tree ??4 medium
13 Word Ladder 127 hard

Advanced Graphs

Number Problem Leetcode Number/Solution Difficulty
1 Reconstruct Itinerary 332 hard
2 Min Cost to Connect All Points 1584 medium
3 Network Delay Time 743 medium
4 Swim in Rising Water 778 hard
5 Foreign Dictionary ??5 hard
6 Cheapest Flights Within K Stops 787 hard

1-D Dynamic programming

Number Problem Leetcode Number/Solution Difficulty
1 Reconstruct Itinerary 70 easy
2 Min Cost Climbing Stairs 746 easy
3 House Robber 198 medium
4 House Robber II 213 medium
5 Longest Palindromic Substring 5 medium
6 Palindromic Substrings 647 medium
7 Decode Ways 91 medium
7 Coin Change 322 medium
8 Maximum Product Subarray 152 medium
9 Word Break 139 medium
10 Longest Increasing Subsequence 300 medium
11 Partition Equal Subset Sum 416 medium

2-D Dynamic programming

Number Problem Leetcode Number/Solution Difficulty
1 Unique Paths 62 medium
2 Longest Common Subsequence 1143 medium
3 Best Time to Buy And Sell Stock With Cooldown 309 medium
4 Coin Change II 518 medium
5 Target Sum 494 medium
6 Interleaving String 97 medium
7 Longest Increasing Path In a Matrix 329 hard
8 Distinct Subsequences 115 hard
9 Edit Distance 72 medium
10 Burst Balloons 312 hard
11 Regular Expression Matching 10 hard

Greedy

Number Problem Leetcode Number/Solution Difficulty
1 Maximum Subarray 53 medium
2 Jump Game 55 medium
3 Jump Game II 45 medium
4 Gas Station 134 medium
5 Hand of Straights 846 medium
6 Merge Triplets to Form Target Triplet 1899 medium
7 Partition Labels 763 medium
8 Valid Parenthesis String 678 medium

Intervals

Number Problem Leetcode Number/Solution Difficulty
1 Insert Interval 57 medium
2 Merge Intervals 56 medium
3 Non Overlapping Intervals 435 medium
4 Meeting Rooms ??6 easy
5 Meeting Rooms II ??7 medium
6 Minimum Interval to Include Each Query 1851 hard

Math & Geometry

Number Problem Leetcode Number/Solution Difficulty
1 Rotate Image 48 medium
2 Spiral Matrix 54 medium
3 Set Matrix Zeroes 73 medium
4 Happy Number 202 easy
5 Plus One 66 easy
6 Pow(x, n) 50 medium
7 Multiply Strings 43 medium
8 Detect Squares 2013 medium

Bit Manipulation

Number Problem Leetcode Number/Solution Difficulty
1 Single Number 136 easy
2 Number of 1 Bits 191 easy
3 Counting Bits 338 easy
4 Reverse Bits 190 easy
5 Missing Number 268 easy
6 Sum of Two Integers 371 medium
7 Reverse Integer 7 medium