Skip to content

dhananjay8/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions - Comprehensive Collection

This repository contains solutions to LeetCode problems organized by difficulty level (Easy, Medium, Hard). All solutions are implemented in JavaScript with Python implementations included as comments.

Final 200 - Easy

Number Problem Name Solution
1 Two Sum Two Sum
2 Valid Palindrome Valid Palindrome
3 Valid Parentheses Valid Parentheses
4 Merge Two Sorted Lists Merge Two Sorted Lists
5 Reverse Linked List Reverse Linked List
6 Linked List Cycle Linked List Cycle
7 Middle of the Linked List Middle of the Linked List
8 Palindrome Linked List Palindrome Linked List
9 Invert Binary Tree Invert Binary Tree
10 Same Tree Same Tree
11 Symmetric Tree Symmetric Tree
12 Maximum Depth of Binary Tree Maximum Depth of Binary Tree
13 Valid Anagram Valid Anagram
14 Ransom Note Ransom Note
15 Isomorphic Strings Isomorphic Strings
16 Contains Duplicate II Contains Duplicate II
17 Happy Number Happy Number
18 Word Pattern Word Pattern
19 Summary Ranges Summary Ranges
20 Remove Duplicates from Sorted Array Remove Duplicates
21 Remove Element Remove Element
22 Merge Sorted Array Merge Sorted Array
23 Majority Element Majority Element
24 Best Time to Buy and Sell Stock Stock I
25 Best Time to Buy and Sell Stock II Stock II
26 Is Subsequence Is Subsequence
27 Plus One Plus One
28 Palindrome Number Palindrome Number
29 Single Number Single Number
30 Longest Common Prefix Longest Common Prefix
31 Length of Last Word Length of Last Word
32 Sqrt(x) Sqrt(x)
33 Number of 1 Bits Number of 1 Bits
34 Find the Index of the First Occurrence in a String Find First Occurrence
35 Reverse Bits Reverse Bits
36 Add Binary Add Binary
37 Search Insert Position Search Insert Position
38 Counting Bits Counting Bits
39 Two Sum II - Input Array Is Sorted Two Sum II
40 Missing Number Missing Number
41 Climbing Stairs Climbing Stairs
42 Roman to Integer Roman to Integer

Final 200 - Medium

Number Problem Name Solution
1 3sum 3sum
2 Container With Most Water Container With Most Water
3 Remove Nth Node From End of List Remove Nth
4 Copy List with Random Pointer Copy List
5 Add Two Numbers Add Two Numbers
6 Add Two Numbers II Add Two Numbers II
7 LRU Cache LRU Cache
8 Lowest Common Ancestor of a Binary Search Tree LCA of BST
9 Lowest Common Ancestor of a Binary Tree LCA of BT
10 Binary Tree Right Side View Right Side View
11 Binary Tree Level Order Traversal Level Order
12 Binary Tree Zigzag Level Order Traversal Zigzag Level Order
13 Validate Binary Search Tree Validate BST
14 Kth Smallest Element in a BST Kth Smallest BST
15 Construct Binary Tree from Preorder and Inorder Traversal Construct Pre+In
16 Construct Binary Tree from Inorder and Postorder Traversal Construct In+Post
17 Populating Next Right Pointers in Each Node II Next Right II
18 Flatten Binary Tree to Linked List Flatten BT
19 Path Sum II Path Sum II
20 Sum Root to Leaf Numbers Sum Root to Leaf
21 Binary Search Tree Iterator BST Iterator
22 Count Complete Tree Nodes Count Nodes
23 Number of Islands Number of Islands
24 Surrounded Regions Surrounded Regions
25 Clone Graph Clone Graph
26 Course Schedule Course Schedule
27 Evaluate Division Evaluate Division
28 Coin Change Coin Change
29 Longest Increasing Subsequence LIS
30 Min Cost Climbing Stairs Min Cost Climbing
31 Maximum Product Subarray Max Product
32 Minimum Size Subarray Sum Min Subarray Sum
33 Longest Substring Without Repeating Characters Longest Substring
34 Find First and Last Position of Element in Sorted Array Find First Last
35 Search a 2D Matrix Search 2D Matrix
36 Search in Rotated Sorted Array Search Rotated
37 Find Minimum in Rotated Sorted Array Find Min Rotated
38 Find Peak Element Find Peak
39 Simplify Path Simplify Path
40 Min Stack Min Stack
41 Valid Sudoku Valid Sudoku
42 Spiral Matrix Spiral Matrix
43 Rotate Image Rotate Image
44 Set Matrix Zeroes Set Matrix Zeroes
45 Game of Life Game of Life
46 Group Anagrams Group Anagrams
47 Longest Consecutive Sequence Longest Consecutive
48 4Sum 4Sum
49 Product of Array Except Self Product Except Self
50 Jump Game Jump Game
51 Jump Game II Jump Game II
52 H-Index H-Index
53 Insert Delete GetRandom O(1) RandomizedSet
54 Gas Station Gas Station
55 Candy Candy
56 Reverse Words in a String Reverse Words
57 Zigzag Conversion Zigzag Conversion
58 Minimum Number of Arrows to Burst Balloons Min Arrows
59 Merge Intervals Merge Intervals
60 Insert Interval Insert Interval
61 Remove Duplicates from Sorted Array II Remove Duplicates II
62 Evaluate Reverse Polish Notation Evaluate RPN
63 House Robber House Robber

Final 200 - Hard

Number Problem Name Solution
1 Basic Calculator Basic Calculator
2 Trapping Rain Water Trapping Rain Water
3 Word Search II Word Search II
4 Median of Two Sorted Arrays Median of Two Sorted Arrays
5 Reverse Nodes in k-Group Reverse Nodes in k-Group
6 Max Points on a Line Max Points on a Line

List of Topic-wise Leetcode Problems:

➤ Array Manipulation & Sorting

  1. Sort Colors ✅
  2. Find All Duplicates in an Array ✅
  3. Missing Number ✅
  4. Find Duplicate Number ✅
  5. Remove Duplicates from Sorted Array ✅
  6. Remove Duplicates from Sorted Array II ✅
  7. Find K Closest Elements ✅
  8. Find Missing Positive Integer
  9. Find Peak Element ✅
  10. Find the Maximum Sum Subarray (Kadane's Algorithm) ✅
  11. Kth Largest Element in an Array ✅
  12. Top K Frequent Elements ✅
  13. Longest Consecutive Sequence ✅
  14. Find the Smallest Range Covering Elements from K Lists
  15. Heapsort
  16. Maximum Gap
  17. Wiggle Sort II

➤ Searching Algorithms (Binary Search & Variants)

  1. Search in Rotated Sorted Array
  2. Search in Rotated Sorted Array II
  3. Find First and Last Position in a Sorted Array
  4. Search Insert Position
  5. Find Minimum in Rotated Sorted Array
  6. Median of Two Sorted Arrays ✅
  7. Search a 2D Matrix

➤ Sliding Window & Substring Problems

  1. Valid Palindrome ✅
  2. Longest Substring Without Repeating Characters ✅
  3. Find All Anagrams in a String ✅
  4. Longest Palindromic Substring
  5. Minimum Window Substring

➤ Intervals & Merging Problems

  1. Summary Ranges ✅
  2. Merge Intervals ✅
  3. Insert Interval ✅
  4. Minimum Absolute Difference
  5. Minimum Number of Arrows to Burst Balloons ✅
  6. Maximum Number of Events That Can Be Attended
  7. Intersection of Two Arrays II

➤ Matrix Problems

  1. Rotate Image
  2. Set Matrix Zeroes
  3. Spiral Matrix
  4. Word Search

➤ Array/String Misc

  1. Find All Anagrams in a String ✅
  2. Subarray Sum Equals K ✅
  3. Minimum Size Subarray Sum ✅
  4. Maximum Product Subarray ✅
  5. Find First and Last Position in a Sorted Array
  6. Count and Say ✅

➤ Hashmaps

  1. Valid Anagram ✅
  2. Ransom Note ✅
  3. Group Anagrams ✅
  4. Isomorphic Strings ✅
  5. Two Sum ✅
  6. Contains Duplicate II ✅
  7. Happy Number ✅

➤ Stacks and Queues

  1. Valid Parentheses ✅
  2. Min Stack ✅
  3. Backspace String Compare
  4. Simplify Path ✅
  5. Evaluate Reverse Polish Notation ✅
  6. Daily Temperatures
  7. Decode String
  8. Basic Calculator ✅
  9. Car Fleet
  10. Generate Parentheses
  11. Asteroid Collision
  12. Basic Calculator II
  13. Maximum Frequency Stack
  14. Longest Valid Parentheses
  15. Largest Rectangle in Histogram

➤ Linked Lists

  1. Reverse Linked List ✅
  2. Merge Two Sorted Lists ✅
  3. Linked List Cycle ✅
  4. Middle of the Linked List ✅
  5. Palindrome Linked List ✅
  6. Remove Nth Node From End of List ✅
  7. Copy List with Random Pointer ✅
  8. Add Two Numbers ✅
  9. Reorder List ✅
  10. Swap Nodes in Pairs ✅
  11. Odd Even Linked List ✅
  12. Sort List ✅
  13. Reverse Nodes in k-Group ✅
  14. Merge K Sorted Lists ✅
  15. LRU Cache ✅

➤ Trees

  1. Invert Binary Tree ✅
  2. Same Tree ✅
  3. Symmetric Tree ✅
  4. Maximum Depth of Binary Tree
  5. Balanced Binary Tree
  6. Subtree of Another Tree
  7. Lowest Common Ancestor of a Binary Search Tree
  8. Diameter of Binary Tree
  9. Path Sum
  10. Count Complete Tree Nodes
  11. Validate Binary Search Tree ✅
  12. Kth Smallest Element in a BST ✅
  13. Construct Binary Tree from Preorder and Inorder Traversal
  14. Binary Tree Level Order Traversal ✅
  15. Binary Tree Zigzag Level Order Traversal
  16. Binary Tree Right Side View
  17. Count Good Nodes in Binary Tree
  18. Flatten Binary Tree to Linked List
  19. Path Sum II
  20. Populating Next Right Pointers in Each Node II
  21. Sum Root to Leaf Numbers
  22. Minimum Absolute Difference in BST
  23. Binary Tree Maximum Path Sum
  24. Serialize and Deserialize Binary Tree
  25. Recover Binary Search Tree

➤ Trie

  1. Implement Trie ✅
  2. Design Add and Search Words Data Structure ✅
  3. Longest Word in Dictionary ✅
  4. Replace Words ✅
  5. Word Search II ✅

➤ Heap

  1. Kth Largest Element in a Stream
  2. Last Stone Weight
  3. Kth Largest Element in an Array ✅
  4. K Closest Points to Origin
  5. Task Scheduler
  6. Top K Frequent Words
  7. Find K Closest Elements ✅
  8. Merge K Sorted Lists
  9. Find Median from Data Stream
  10. Sliding Window Median

➤ Backtracking

  1. N-Queens
  2. Sudoku Solver
  3. Word Search
  4. Subsets
  5. Permutations
  6. Combination Sum
  7. Generate Parentheses
  8. Palindrome Partitioning
  9. Letter Combinations of a Phone Number
  10. Restore IP Addresses

➤ Graphs

  1. Flood Fill
  2. Number of Islands
  3. Max Area of Island
  4. Clone Graph
  5. Course Schedule
  6. Course Schedule II
  7. Pacific Atlantic Water Flow
  8. Rotting Oranges
  9. Surrounded Regions
  10. Walls and Gates
  11. Graph Valid Tree
  12. Number of Connected Components in an Undirected Graph
  13. Redundant Connection
  14. Find Eventual Safe States
  15. Network Delay Time
  16. Path with Maximum Probability
  17. Word Ladder
  18. Shortest Path in a Grid with Obstacles Elimination
  19. Alien Dictionary
  20. Find Strongly Connected Components

➤ Dynamic Programming

  1. Climbing Stairs ✅
  2. Coin Change ✅
  3. Word Break ✅
  4. House Robber ✅
  5. Paint House
  6. Unique Paths II
  7. 0/1 Knapsack Problem
  8. Palindromic Substrings
  9. Decode Ways
  10. Unique Paths
  11. Shortest Common Supersequence
  12. Interleaving String
  13. House Robber II
  14. Minimum Path Sum
  15. Maximal Square
  16. Longest Increasing Subsequence
  17. Can I Win
  18. Ones and Zeroes
  19. Longest Palindromic Subsequence
  20. Partition Equal Subset Sum / Partition to K Equal Sum Subset
  21. Cheapest Flights Within K Stop
  22. Longest Arithmetic Sequence
  23. Last Stone Weight II
  24. Filling Bookcase Shelves
  25. Longest Common Subsequence
  26. Dice Roll Sum
  27. Longest Valid Parentheses
  28. Wildcard Matching
  29. Edit Distance
  30. Best Time to Buy and Sell Stocks
  31. Burst Balloons
  32. Minimum Cost to Merge Stones
  33. Minimum Difficulty of a Job Schedule

➤ Greedy Algorithms

  1. Activity Selection Problem
  2. Huffman Encoding
  3. Minimum Platforms
  4. Job Sequencing Problem
  5. Jump Game
  6. Gas Station ✅
  7. Partition Labels
  8. Dijkstra's Algorithm
  9. Trapping Rain Water ✅
  10. Largest Rectangle in Histogram
  11. Container With Most Water ✅
  12. Reorganize String

➤ Bit Manipulation, Maths, Misc

  1. Single Number
  2. Number of 1 Bits
  3. Counting Bits
  4. Reverse Bits
  5. Add Binary
  6. Divide Two Integers
  7. Single Number II
  8. Bitwise AND of Numbers Range
  9. Palindrome Number
  10. Plus One
  11. Pow(x, n)
  12. Factorial Trailing Zeroes
  13. Multiply Strings

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published