Skip to content

Latest commit

 

History

History
561 lines (473 loc) · 78.5 KB

README.md

File metadata and controls

561 lines (473 loc) · 78.5 KB

Awesome Leetcode

LOC visitor count Stars Badge Forks Badge GitHub contributors

If you appreciate my work, please 🌟 this repository. It motivates me. 🚀🚀

1. Backtracking

S.No Problem Difficulty Solution
1 Generate Parentheses Medium Solution
2 Combination Sum Medium Solution
3 Permutations Medium Solution
4 Letter Combinations of a Phone Number Medium Solution
5 Generate Parentheses Medium Solution
6 Sudoku Solver Medium Solution
7 Combination Sum II Medium Solution
8 Permutations II Medium Solution
9 N Queens Medium Solution
10 Combinations Medium Solution
11 Subsets Medium Solution
12 Word Search Medium Solution
13 Subsets II Medium Solution
14 Palindrome Partitioning Medium Solution
15 Combination Sum III Medium Solution

2. Base Conversion

S.No Problem Difficulty Solution
1 Find Unique Binary String Medium Solution

3. Bellman Ford

S.No Problem Difficulty Solution
1 Cheapest Flights Within K Stops Medium Solution
2 Network Delay Time Medium Solution

4. BFS

S.No Problem Difficulty Solution
1 Average of Levels In Binary Tree Easy Solution
2 Number of Islands Medium Solution

5. Binary Search

S.No Problem Difficulty Solution
1 Search In Rotated Sorted Array Medium Solution
2 Find First and Last Position of Element In Sorted Array Medium Solution
3 Minimize Maximum of Array Medium Solution

6. Binary Trees

S.No Problem Difficulty Solution
1 Sum of Leaft Leaves Easy Solution
2 Construct String From Binary Tree Easy Solution
3 Average of Levels In Binary Tree Easy Solution
4 Balanced Binary Tree Easy Solution
5 Convert Sorted Array To Binary Search Tree Easy Solution
6 Sum Root To Leaf Numbers Medium Solution
7 Kth Smallest Element in a BST Medium Solution
8 Lowest Common Ancestor Of A Binary Tree Medium Solution
9 Serialize and Deserialize BST Medium Solution
10 Construct Binary Tree From Inorder and Postorder Traversal Medium Solution
11 Construct Binary Tree From Preorder and Inorder Traversal Medium Solution
12 Binary Tree Pruning Medium Solution
13 All Nodes Distance K In Binary Tree Medium Solution
14 Distribute Coins In Binary Tree Medium Solution
15 Vertical Order Traversal of A Binary Tree Hard Solution

7. Bit Manipulation

S.No Problem Difficulty Solution
1 Power of Two Easy Solution
2 Divide Array Into Equal Pairs Easy Solution
3 Divide Two Integers Medium Solution
4 Subsets Medium Solution
5 Subsets II Medium Solution
6 Check If A String Contains All Binary Codes of Size K Medium Solution
7 Concatenation of Consecutive Binary Numbers Medium Solution
8 Count Number of Maximum Bitwise OR Subsets Medium Solution
9 Largest Combination With Bitwise AND Greater Than Zero Medium Solution
10 Maximum XOR After Operations Medium Solution
11 Smallest Subarrays With Maximum Bitwise OR Medium Solution
12 Longest Subarray With Maximum Bitwise AND Medium Solution
13 Minimize XOR Medium Solution
14 Bitwise XOR of All Pairings Medium Solution
15 Closest Subsequence Sum Hard Solution
16 Find The Shortest Superstring Hard Solution
17 Number of One Bits Easy Solution

8. Bitmasks

S.No Problem Difficulty Solution
1 Fair Distribution of Cookies Medium Solution
2 Count Number of Maximum Bitwise OR Subsets Medium Solution

9. Count Pairs In Array

S.No Problem Difficulty Solution
1 Count Nice Pairs In An Array Medium Solution
2 Count Number of Bad Pairs Medium Solution

10. Custom Comparator

S.No Problem Difficulty Solution
1 Sort The People Medium Solution
2 Sort Array By Parity Medium Solution
3 Bitwise XOR of All Pairings Medium Solution

11. Design and Implementation

S.No Problem Difficulty Solution
1 Implement Queue Using Stacks Easy Solution
2 Implement Stack Using Queues Easy Solution
3 Stock Price Fluctuation Medium Solution
4 Design Circular Deque Medium Solution
5 LRU Cache Medium Solution
6 Time Based Key Value Store Medium Solution
7 Operations On Tree Medium Solution
8 Design Circular Queue Medium Solution
9 Design Movie Rental System Hard Solution
10 Design A Text Editor Hard Solution

12. DFS

S.No Problem Difficulty Solution
1 Flood Fill Easy Solution
2 Is Graph Bipartite? Medium Solution
3 Keys and Rooms Medium Solution
4 Out of Boundary Paths Medium Solution
5 Number of Provinces Medium Solution
6 Pacific Atlantic Water Flow Medium Solution
7 Interleaving String Medium Solution
8 Shortest Bridge Medium Solution
9 Throne Inheritance Medium Solution
10 Detonate The Maximum Bombs Medium Solution
11 Longest Path With Different Adjacent Characters Hard Solution
12 Create Components With Same Value Hard Solution
13 Restore the Array From Adjacent Pairs Medium Solution

13. Dijkstra

S.No Problem Difficulty Solution
1 Network Delay Time Medium Solution
2 Cheapest Flights Within K Stops Medium Solution
3 Path With Maximum Probability Medium Solution
4 Find The City With The Smallest Number of Neighbors At A Threshold Distance Medium Solution
5 Path With Minimum Effort Medium Solution
6 Number of Restricted Paths From First To Last Node Medium Solution
7 Number of Ways To Arrive At Destination Medium Solution
8 Minimum Cost To Reach Destination In Time Medium Solution
9 Minimum Cost To Make At Least One Valid Path In A Grid Hard Solution
10 Reachable Nodes in Subdivided Graph Hard Solution
11 Design Graph With Shortest Path Calculator Hard Solution

14. Dynamic Programming

S.No Problem Difficulty Solution
1 Climbing Stairs Easy Solution
2 Pascal's Triangle Easy Solution
3 Best Time To Buy and Sell Stock Easy Solution
4 Jump Game Medium Solution
5 Unique Paths Medium Solution
6 Decode Ways Medium Solution
7 Maximum Product Subarray Medium Solution
8 House Robber Medium Solution
9 Word Break Medium Solution
10 Coin Change Medium Solution
11 Count Number of Texts Medium Solution

15. Euler Circuit

S.No Problem Difficulty Solution
1 Reconstruct Itinerary Hard Solution
2 Cracking The Safe Hard Solution
3 Valid Arrangement of Pairs Hard Solution

16. Fenwick Tree

S.No Problem Difficulty Solution
1 Shifting Letters II Medium Solution
2 Queries On A Permutation With Key Medium Solution
3 Create Sorted Array Through Instructions Hard Solution
4 Count Good Triplets In An Array Hard Solution

17. Greedy Scheduling

S.No Problem Difficulty Solution
1 Maximum Number of Events That Can Be Attended Medium Solution
2 Single Threaded CPU Medium Solution

18. Heaps (Priority Queues)

S.No Problem Difficulty Solution
1 Sort Array By Increasing Frequency Easy Solution
2 Kth Largest Element in An Array Medium Solution
3 Top K Frequent Elements Medium Solution
4 Sort Characters By Frequency Medium Solution
5 Find K Closest Elements Medium Solution
6 Top K Frequent Words Medium Solution
7 K Closest Points To Origin Medium Solution
8 Reduce Array Size To The Half Medium Solution
9 Reorganize String Medium Solution
10 Sender With Largest Word Count Medium Solution
11 Minimum Difference In Sums After Removal of Elements Hard Solution
12 Course Schedule III Hard Solution
13 Maximum Frequency Stack Hard Solution

19. Intervals

S.No Problem Difficulty Solution
1 Merge Intervals Medium Solution
2 Insert Interval Medium Solution
3 Non Overlapping Intervals Medium Solution
4 Minimum Number of Arrows To Burst Balloons Medium Solution
5 My Calendar I Medium Solution
6 Video Stitching Medium Solution

20. Line Sweep

S.No Problem Difficulty Solution
1 Maximum Population Year Easy Solution
2 Divide Intervals Into Minimum Number of Groups Medium Solution
3 Shifting Letters II Medium Solution
4 Describe The Painting Medium Solution
5 Minimum Absolute Difference Queries Medium Solution
6 Car Pooling Medium Solution
7 Corporate Flight Bookings Medium Solution
8 My Calendar II Medium Solution
9 Minimum Interval To Include Each Query Hard Solution
10 My Calendar III Hard Solution
11 The Skyline Problem Hard Solution
12 Number of Flowers In Full Bloom Hard Solution

21. Linked List

S.No Problem Difficulty Solution
1 Merge Two Sorted Lists Easy Solution
2 Remove Duplicates From Sorted List Easy Solution
3 Linked List Cycle Easy Solution
4 Palindrome Linked List Easy Solution
5 Middle of The Linked List Easy Solution
6 Intersection of Two Linked List Easy Solution
7 Add Two Numbers Medium Solution
8 Remove Nth Node From End of List Medium Solution
9 Rotate List Medium Solution
10 Next Greater Node In Linked List Medium Solution
11 Sort List Medium Solution
12 Reorder List Medium Solution
13 Linked List Cycle II Medium Solution
14 Remove Duplicates From Sorted List II Medium Solution
15 Partition List Medium Solution
16 Reverse Linked List II Medium Solution
17 Flatten Binary Tree To Linked List Medium Solution
18 Populating Next Right Pointers In Each Node Medium Solution
19 Copy List With Random Pointers Medium Solution
20 Delete Node In A Linked List Medium Solution
21 Odd Even Linked List Medium Solution
22 Swapping Nodes In A Linked List Medium Solution
23 Merge Nodes In Between Zeros Medium Solution
24 Reverse Nodes In K Group Hard Solution
25 Merge K Sorted Lists Hard Solution

22. LIS

S.No Problem Difficulty Solution
1 Longest Increasing Subsequence Medium Solution
2 Increasing Triplet Subsequence Medium Solution
3 Minimum Number of Removals To Make Mountain Array Hard Solution
4 Find The Longest Valid Obstacle Course At Each Position Hard Solution

23. Manacher

S.No Problem Difficulty Solution
1 Longest Palindromic Substring Medium Solution
2 Maximum Product of The Length of Two Palindromic Substrings Hard Solution

24. Matrix

S.No Problem Difficulty Solution
1 Transpost Matrix Easy Solution
2 Count Submatrices With All Ones Medium Solution
3 Maximal Square Medium Solution
4 Shortest Path In Binary Matrix Medium Solution
5 Sort The Matrix Diagonally Medium Solution
6 Count Square Submatrices With All Ones Medium Solution
7 Number of Submatrices That Sum To Target Hard Solution
8 Maximal Rectangle Hard Solution

25. Merge Sort

S.No Problem Difficulty Solution
1 Sort List Medium Solution
2 Count of Smaller Numbers After Self Medium Solution
3 Count of Range Sum Medium Solution
4 Reverse Pairs Medium Solution
5 Number of Pairs Satisfying Inequality Medium Solution

26. Minimum Spanning Trees

S.No Problem Difficulty Solution
1 Min Cost To Connect All Points Medium Solution
2 Find Critical And Pseudo Critical Edges in Minimum Spanning Tree Medium Solution

27. Prefix State Map

S.No Problem Difficulty Solution
1 Contiguous Array Medium Solution
2 Find The Longest Substring Containing Vowels In Even Counts Medium Solution
3 Find Longest Awesome Substring Medium Solution
4 Number of Wonderful Substrings Medium Solution

28. Queries

S.No Problem Difficulty Solution
1 Most Beautiful Item For Each Query Medium Solution
2 Queries On Number of Points Inside A Circle Medium Solution
3 Range Frequency Queries Medium Solution
4 XOR Queries of a Subarray Medium Solution
5 Queries On A Permutation With Key Medium Solution
6 Subrectangle Queries Medium Solution
7 Minimum Absolute Difference Queries Medium Solution
8 Maximum Genetic Difference Query Hard Solution

29. Rolling Hash

S.No Problem Difficulty Solution
1 Repeated DNA Sequences Medium Solution
2 Shortest Palindrome Medium Solution
3 Longest Duplicate Substring Medium Solution
4 Distinct Echo Substrings Medium Solution
5 K Divisible Elements Subarrays Medium Solution
6 Sum of Scores of Built Strings Hard Solution
7 Find Substring With Given Hash Value Hard Solution
8 Longest Common Subpath Hard Solution

30. Segment Tree

S.No Problem Difficulty Solution
1 Sum of Even Numbers After Queries Medium Solution
2 Range Sum Query - Mutable Medium Solution
3 Longest Increasing Subseqence - II Medium Solution
4 Shifting Letters - II Medium Solution
5 Falling Squares Hard Solution

31. Sets

S.No Problem Difficulty Solution
1 Find All Numbers Disappeared in an Array Medium Solution

32. Sieve of Eratosthenes

S.No Problem Difficulty Solution
1 Count Primes Medium Solution
2 Four Divisors Medium Solution

33. Sliding Window

S.No Problem Difficulty Solution
1 Longest Substring Without Repeating Characters Medium Solution
2 Minimum Size Subarray Sum Medium Solution
3 Number of Smooth Descent Periods of Stock Medium Solution
4 Maximize The Confusion of An Exam Medium Solution
5 Frequency of Most Frequent Element Medium Solution
6 Max Consecutive Ones - III Medium Solution
7 Longest Repeating Character Replacement Medium Solution
8 Permutation In String Medium Solution
9 Minimum Window Substring Hard Solution
10 Substring With Concatenation Of All Words Hard Solution
11 Count Subarrays With Fixed Count Hard Solution

34. Stack

S.No Problem Difficulty Solution
1 Valid Parentheses Easy Solution
2 Implement Queue Using Stacks Easy Solution
3 Next Greater Element I Easy Solution
4 Backspace String Compare Easy Solution
5 Min Stack Medium Solution
6 Next Greater Element II Medium Solution
7 132 Patterns Medium Solution
8 Daily Temperatures Medium Solution
9 Score of Parentheses Medium Solution
10 Validate Stack Sequences Medium Solution
11 Next Greater Node In Linked List Medium Solution
12 The Number of Weak Characters In The Game Medium Solution
13 Construct Smallest Number From DI String Medium Solution
14 Maximum Frequency Stack Medium Solution
15 Basic Calculator Medium Solution
16 Longest Valid Parentheses Medium Solution
17 Using A Robot To Print The Lexicographically Smallest String Medium Solution

35. Stringstream

S.No Problem Difficulty Solution
1 Reverse Words In A String-III Medium Solution
2 Find Duplicate File In System Medium Solution
3 Apply Discount To Prices Medium Solution

36. Sum of First N Natural Numbers

S.No Problem Difficulty Solution
1 Count Number of Homogenous Substrings Medium Solution
2 Number of Substrings With Only 1s Medium Solution

37. Topological Sort

S.No Problem Difficulty Solution
1 Course Schedule Medium Solution
2 Course Schedule II Medium Solution
3 Minimum Height Trees Medium Solution
4 Longest Incresing Path In A Matrix Medium Solution
5 All Ancestors of a Node In Directed Acyclic Graph Medium Solution
6 Number of Ways To Arrive At Destination Medium Solution
7 Parallel Courses III Hard Solution
8 Build A Matrix With Conditions Hard Solution

38. Trie

S.No Problem Difficulty Solution
1 Implement Trie (Prefix Tree) Medium Solution
2 Search Suggestions System Medium Solution
3 Maximum XOR of Two Numbers In An Array Medium Solution
4 K Divisible Elements Subarray Medium Solution
5 Maximum Genetic Difference Query Hard Solution
6 Concatenated Words Hard Solution
7 Palindrome Pairs Hard Solution
8 Sum of Prefix Scores of Strings Hard Solution

39. Two Dimensional Plane

S.No Problem Difficulty Solution
1 Max Points On A Line Medium Solution
2 Min Cost To Connect All Points Medium Solution
3 Queries On Number of Points Inside A Circle Medium Solution
4 Detonate The Maximum Bombs Medium Solution

40. Two Pointer

S.No Problem Difficulty Solution
1 Two Sum Easy Solution
2 Remove Duplicates From Sorted List Easy Solution
3 Linked List Cycle Easy Solution
4 Add Two Numbers Medium Solution
5 Container With Most Water Medium Solution
6 3Sum Medium Solution
7 3Sum Closest Medium Solution
8 Remove Nth Node From End of List Medium Solution
9 Trapping Rain Water Medium Solution
10 Sort Colors Medium Solution
11 Minimum Window Substring Medium Solution
12 Linked List Cycle-II Medium Solution
13 Reorder List Medium Solution
14 Sort List Medium Solution
15 Maximum Product Subarray Medium Solution
16 Lexicographically Smallest Palindrome Medium Solution

41. Union Find

S.No Problem Difficulty Solution
1 Longest Consecutive Sequence Medium Solution
2 Number of Islands Medium Solution
3 Number of Provinces Medium Solution
4 Redundant Connections Medium Solution
5 Max Area of Island Medium Solution
6 Is Graph Bipartite ? Medium Solution
7 Satifiability of Equality Equations Medium Solution
8 Smallest String With Swaps Medium Solution
9 Number of Good Paths Medium Solution

kiranpalsingh