Skip to content

Latest commit

 

History

303 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation


Problems Solved Language SQL 50 Pandas Platform


> About Repo:

A collection of Python DSA and SQL solutions organized for interview preparation.

Built to improve problem-solving skills, maintain consistency, and prepare for coding interviews.

Every problem here is chosen. Every solution is understood.


> Goals:

-- Solve 150+ quality DSA problems.
-- Complete LeetCode SQL 50.
-- Master pattern-based problem recognition.
-- Build strong problem-solving skills.
-- Strengthen SQL for interviews.
-- Maintain daily consistency.
-- Build a strong DSA foundation.
-- Crack placements & coding interviews.

> Patterns Covered:

Click any section to expand.

Python DSA
Arrays
# Problem Pattern Complexity
27 Remove Element Two Pointers O(n)
41 First Missing Positive Cyclic Sort / Index Placement O(n)
48 Rotate Image Matrix Manipulation O(n^2)
53 Maximum Subarray Kadane's Algorithm O(n)
66 Plus One Simulation / Arrays O(n)
121 Best Time to Buy and Sell Stock Prefix Minimum O(n)
169 Majority Element Boyer-Moore Voting O(n)
189 Rotate Array Reversal Technique O(n)
228 Summary Ranges Arrays / Two Pointers O(n)
238 Product of Array Except Self Prefix / Suffix Product O(n)
268 Missing Number Math / XOR O(n)
349 Intersection of Two Arrays Hash Set / Arrays O(n + m)
396 Rotate Function Math / Prefix Optimization O(n)
448 Find All Numbers Disappeared in an Array Arrays / In-Place Marking O(n)
628 Maximum Product of Three Numbers Arrays / Sorting O(n log n)
912 Sort an Array Merge Sort O(n log n)
914 Cyclically Rotating a Grid Matrix Simulation O(m * n)
1260 Shift 2D Grid Arrays / Matrix O(m × n)
1331 Rank Transform of an Array Arrays / Hash Map O(n log n)
1365 How Many Numbers Are Smaller Than the Current Number Brute Force / Arrays O(n^2)
1431 Kids With the Greatest Number of Candies Arrays O(n)
1464 Maximum Product of Two Elements in an Array Arrays / Greedy O(n)
1752 Check if Array Is Sorted and Rotated Arrays O(n)
1848 Minimum Distance to the Target Element Arrays O(n)
1861 Rotating the Box Matrix Simulation O(m * n)
2033 Minimum Operations to Make a Uni-Value Grid Math / Median O(m*n log(m*n))
2078 Two Furthest Houses With Different Colors Greedy O(n)
2161 Partition Array According to Given Pivot Partitioning O(n)
2515 Shortest Distance to Target String in a Circular Array Simulation O(n)
2553 Separate the Digits in an Array Simulation / Arrays O(total digits)
2615 Sum of Distances Array / Hashing / Prefix Sum O(n)
2784 Check if Array is Good Sorting / Arrays O(n log n)
2996 Smallest Missing Integer Greater Than Sequential Prefix Sum Arrays / Hash Set O(n)
3300 Minimum Element After Replacement With Digit Sum Math / Arrays O(n * d)
3488 Closest Equal Element Queries Hashing / Circular Array O(n)
3741 Minimum Distance Between Three Equal Elements II Hashing O(n)
3740 Minimum Distance Between Three Equal Elements I Hashing O(n)
3761 Minimum Absolute Distance Between Mirror Pairs Hashing O(n)
3737 Count Subarrays With Majority Element I Brute Force O(n²)
3739 Count Subarrays With Majority Element II Prefix Sum / Ordered Set O(n log n)
Count Indices With Opposite Parity Prefix / Counting O(n)

Backtracking
# Problem Pattern Complexity
1291 Sequential Digits Backtracking / Enumeration O(1)

Binary-Search
# Problem Pattern Complexity
33 Search in Rotated Sorted Array Binary Search O(log n)
34 Find First and Last Position of Element in Sorted Array Binary Search O(log n)
35 Search Insert Position Binary Search O(log n)
69 Sqrt(x) Binary Search O(log x)
153 Find Minimum in Rotated Sorted Array Binary Search O(log n)
154 Find Minimum in Rotated Sorted Array II Binary Search O(log n) avg
405 Convert a Number to Hexadecimal Bit Manipulation / Number System O(log n)
3464 Maximize the Distance Between Points on a Square Binary Search / Geometry O(n log n log P)

Bit-Manipulation
# Problem Pattern Complexity
136 Single Number Bit Manipulation / XOR O(n)
190 Reverse Bits Bit Manipulation O(1)
231 Power of Two Bit Manipulation O(1)
389 Find the Difference Bit Manipulation / XOR O(n)
3513 Number of Unique XOR Triplets I Bit Manipulation / Mathematics O(1)
3514 Number of Unique XOR Triplets II Bit Manipulation / Hash Set O(u² + u × p)
3702 Longest Subsequence With Non-Zero Bitwise XOR Bit Manipulation / XOR / Greedy O(n)

Dyanmc Programming
# Problem Pattern Complexity
70 Climbing Stairs Fibonacci / DP O(n)
338 Counting Bits DP / Bit Manipulation O(n)
486 Predict the Winner Dynamic Programming / Game Theory O(n²)
877 Stone Game Dynamic Programming / Game Theory O(n²)
1140 Stone Game II Dynamic Programming / Game Theory / Memoization O(n³)
1301 Number of Paths with Max Score Dynamic Programming O(n²)
1320 Minimum Distance to Type a Word Using Two Fingers DP O(26 * n)
1340 Jump Game V DFS Memoization / DP O(n * d)
1406 Stone Game III Dynamic Programming / Game Theory O(n)
1510 Stone Game IV Dynamic Programming / Game Theory O(n√n)
1563 Stone Game V Dynamic Programming / Prefix Sum / Game Theory O(n²)
1871 Jump Game VII DP / Sliding Window O(n)
2463 Minimum Total Distance Traveled DP / Sorting O(n * m * k)
2770 Maximum Number of Jumps to Reach the Last Index Dynamic Programming O(n^2)
3225 Maximum Score From Grid Operations DP / Prefix Sum O(n^3)
3336 Find the Number of Subsequences With Equal GCD Dynamic Programming / GCD DP O(n × S)
3348 Smallest Divisible Digit Product II Dynamic Programming / Greedy / Mathematics O(S + n)
3418 Maximum Amount of Money Robot Can Earn Grid DP O(m * n)
3660 Jump Game IX DP / Prefix-Suffix O(n)
3661 Maximum Walls Destroyed by Robots DP / Memoization / Binary Search O(n log m)
3699 Number of ZigZag Arrays I Dynamic Programming O(n × m)
3700 Number of ZigZag Arrays II DP / Matrix Exponentiation O((2m)^3 log n)
3742 Maximum Path Score in a Grid Grid DP / Knapsack O(m * n * k)

Graphs
# Problem Pattern Complexity
133 Clone Graph DFS / Hash Map O(V + E)
200 Number of Islands DFS / Matrix Traversal O(m * n)
695 Max Area of Island DFS / Matrix Traversal O(m * n)
1306 Jump Game III BFS / Graph Traversal O(n)
1345 Jump Game IV BFS / Graph Traversal O(n)
1391 Check if There is a Valid Path in a Grid BFS / Matrix Traversal O(m * n)
1559 Detect Cycles in 2D Grid DFS / Matrix Traversal O(m * n)
1722 Minimize Hamming Distance After Swap Operations Union Find / Hashing O(n α(n))
2492 Minimum Score of a Path Between Two Cities DFS O(n + m)
2685 Count the Number of Complete Components Union Find (DSU) O((n + m) · α(n))
2812 Find the Safest Path in a Grid Multi-Source BFS / Dijkstra O(n² log n)
3286 Find a Safe Walk Through a Grid Graphs / 0-1 BFS O(m × n)
3310 Remove Methods From Project Graph / BFS O(n + m)
3532 Path Existence Queries in a Graph I Connected Components O(n + q)
3534 Path Existence Queries in a Graph II Binary Lifting O((n + q) log n)
3620 Network Recovery Pathways Binary Search / DAG DP O((n + m) log m)
3629 Minimum Jumps to Reach End via Prime Teleportation BFS / Number Theory O(n log log M)

Greedy
# Problem Pattern Complexity
45 Jump Game II Greedy O(n)
55 Jump Game Greedy O(n)
455 Assign Cookies Greedy / Two Pointers O(n log n + m log m)
561 Array Partition Greedy / Sorting O(n log n)
605 Can Place Flowers Greedy O(n)
976 Largest Perimeter Triangle Greedy / Sorting O(n log n)
1081 Smallest Subsequence of Distinct Characters Greedy / Monotonic Stack O(n)
1288 Remove Covered Intervals Greedy / Sorting O(n log n)
1665 Minimum Initial Energy to Finish Tasks Greedy / Sorting O(n log n)
1833 Maximum Ice Cream Bars Greedy / Sorting O(n log n)
1840 Maximum Building Height Greedy / Constraint Propagation O(m log m)
1846 Maximum Element After Decreasing and Rearranging Greedy / Sorting O(n log n)
2126 Destroying Asteroids Greedy / Sorting O(n log n)
2144 Minimum Cost of Buying Candies With Discount Greedy / Sorting O(n log n)
3014 Minimum Number of Pushes to Type Word I Greedy / Hash Map O(n log n)
3016 Minimum Number of Pushes to Type Word II Greedy / Frequency Counting O(n)
3302 Find the Lexicographically Smallest Valid Sequence Greedy / String Matching O(n + m)
3474 Lexicographically Smallest Generated String String Construction O(n * m)
3499 Maximize Active Section with Trade I Greedy / Strings O(n)
3501 Maximize Active Section with Trade II Greedy / Sparse Table / Binary Search O(n log n + q log n)
3633 Earliest Finish Time for Land and Water Rides I Greedy / Simulation O(n * m)
3635 Earliest Finish Time for Land and Water Rides II Greedy O(n + m)
3689 Maximum Total Subarray Value I Greedy / Math O(n)
3691 Maximum Total Subarray Value II Greedy / Heap / Sparse Table O(n log n + k log k)

Hashing
# Problem Pattern Complexity
1 Two Sum HashMap Lookup O(n)
36 Valid Sudoku HashSet Validation O(1)
49 Group Anagrams HashMap + Sorted String O(n log n)
128 Longest Consecutive Sequence HashSet / Sequence Expansion O(n)
205 Isomorphic Strings Bi-directional HashMap O(n)
217 Contains Duplicate HashSet O(n)
219 Contains Duplicate II HashMap / Sliding Window O(n)
242 Valid Anagram Frequency Count O(n)
290 Word Pattern Bi-directional HashMap O(n)
347 Top K Frequent Elements Frequency Count / Bucket Sort O(n)
350 Intersection of Two Arrays II Hash Map / Counting O(n + m)
387 First Unique Character in a String Hash Map / Counting O(n)
451 Sort Characters By Frequency Frequency Count / Bucket Sort O(n)
454 4Sum II Pair Sum + HashMap O(n²)
697 Degree of an Array Hash Map / Frequency Counting O(n)
874 Walking Robot Simulation Simulation / Hash Set O(n + m)
3020 Find the Maximum Number of Elements in Subset Hash Map / Greedy O(n · log log M)
3043 Find the Length of the Longest Common Prefix Hash Set / Prefix Matching O((n+m) * d)
3731 Find Missing Elements Hash Set O(n + r)

Linked List
# Problem Pattern Complexity
2 Add Two Numbers Linked List O(max(n,m))
21 Merge Two Sorted Lists Linked List / Two Pointers O(n + m)
61 Rotate List Two Pointers / Linked List O(n)
83 Remove Duplicates from Sorted List Linked List / Two Pointers O(n)
203 Remove Linked List Elements Linked List / Dummy Node O(n)
234 Palindrome Linked List Linked List / Fast & Slow Pointers O(n)
2095 Delete the Middle Node of a Linked List Fast & Slow Pointers O(n)
2130 Maximum Twin Sum of a Linked List Fast & Slow Pointers / Linked List Reversal O(n)

Math
# Problem Pattern Complexity
7 Reverse Integer Number Manipulation O(log n)
9 Palindrome Number Number Manipulation O(log n)
168 Excel Sheet Column Title Mathematics / Base Conversion O(log₍₂₆₎ n)
171 Excel Sheet Column Number Mathematics / Base Conversion O(n)
202 Happy Number Math / Hash Set O(log n)
412 Fizz Buzz Simulation / Math O(n)
788 Rotated Digits Digit Check / Math O(n * d)
1344 Angle Between Hands of a Clock Math / Geometry O(1)
1523 Count Odd Numbers in an Interval Range Math O(1)
1979 Find Greatest Common Divisor of Array Mathematics / GCD O(n + log(max(nums)))
2029 Stone Game IX Game Theory / Mathematics / Modular Arithmetic O(n)
2520 Count the Digits That Divide a Number Number Manipulation O(d)
3312 Sorted GCD Pair Queries Number Theory / Inclusion-Exclusion O(M log M + Q log M)
3345 Smallest Divisible Digit Product I Mathematics / Brute Force O(k × d)
3536 Maximum Product of Two Digits Mathematics / Sorting O(d log d)
3653 XOR After Range Multiplication Queries I Simulation / Math O(total updates)
3655 XOR After Range Multiplication Queries II Math / Sqrt Decomposition O(q * sqrt(n) + n * sqrt(n))
3658 GCD of Odd and Even Sums Mathematics / Number Theory O(1)
3751 Total Waviness of Numbers in Range I Math / Simulation O((num2-num1) * D)
3753 Total Waviness of Numbers in Range II Math / Digit DP / Counting O(1)
3783 Mirror Distance of an Integer Math O(d)
3867 Sum of GCD of Formed Pairs Mathematics / GCD / Sorting O(n log n)
Sum of Primes Between Number and Its Reverse Prime Checking O(n√n)

Prefix Sum
# Problem Pattern Complexity
303 Range Sum Query - Immutable Prefix Sum O(1) query
560 Subarray Sum Equals K Prefix Sum + HashMap O(n)
1674 Minimum Moves to Make Array Complementary Prefix Sum / Sweep Line O(n + limit)
1732 Find the Highest Altitude Prefix Sum O(n)
2574 Left and Right Sum Differences Prefix Sum O(n)
2657 Find the Prefix Common Array of Two Arrays Hashing / Prefix O(n)

Sliding Window
# Problem Pattern Complexity
3 Longest Substring Without Repeating Characters Sliding Window / Hash Set O(n)
1358 Number of Substrings Containing All Three Characters Sliding Window / Two Pointers O(n)
2958 Length of Longest Subarray With at Most K Frequency Sliding Window / Hash Map O(n)
3090 Maximum Length Substring With Two Occurrences Sliding Window / Hash Map O(n)

Stack
# Problem Pattern Complexity
20 Valid Parentheses Stack O(n)
2751 Robot Collisions Stack / Simulation O(n log n)

Strings
# Problem Pattern Complexity
5 Longest Palindromic Substring Expand Around Center O(n^2)
6 Zigzag Conversion Simulation / Strings O(n)
13 Roman to Integer Hashing / Strings O(n)
14 Longest Common Prefix Strings O(S)
28 Find the Index of the First Occurrence in a String Strings / Sliding Window O((n-m+1)*m)
58 Length of Last Word Strings O(n)
67 Add Binary Simulation / Strings O(max(n,m))
345 Reverse Vowels of a String Strings / Two Pointers O(n)
409 Longest Palindrome Hashing / Strings O(n)
657 Robot Return to Origin Simulation O(n)
796 Rotate String Strings O(n)
1071 Greatest Common Divisor of Strings Strings / Mathematics O(n + m)
1189 Maximum Number of Balloons Hash Map / Counting O(n)
1768 Merge Strings Alternately Strings / Two Pointers O(n + m)
1967 Number of Strings That Appear as Substrings in Word Strings O(n × m)
2069 Walking Robot Simulation II Simulation / Design O(1)
2075 Decode the Slanted Ciphertext Matrix Traversal O(n)
2213 Longest Substring of One Repeating Character Segment Tree / String O(n + q log n)
2452 Words Within Two Edits of Dictionary Brute Force / Strings O(q * d * L)
2833 Furthest Point From Origin Counting / Strings O(n)
2840 Check if Strings Can be Made Equal With Operations II Even/Odd Index Grouping + Sorting O(n log n)
3093 Longest Common Suffix Queries Trie / Strings O(total chars)
3120 Count the Number of Special Characters I Hash Set / Strings O(n)
3121 Count the Number of Special Characters II Hashing / Strings O(n)
3517 Smallest Palindromic Rearrangement I Strings / Greedy / Hash Map O(n + k log k)
3518 Smallest Palindromic Rearrangement II Strings / Greedy / Combinatorics O(n + m × k)
3612 Process String with Special Operations I Simulation O(n)
3614 Process String with Special Operations II Reverse Simulation O(n)
3754 Concatenate Non-Zero Digits and Multiply by Sum I Strings / Simulation O(d)
3838 Weighted Word Mapping Strings / Simulation O(n × m)

Trees
# Problem Pattern Complexity
2196 Create Binary Tree From Descriptions Trees / Hash Map O(n)
3161 Block Placement Queries Segment Tree / Sorted List O(q log n)
3558 Number of Ways to Assign Edge Weights I BFS / Combinatorics O(n)
3559 Number of Ways to Assign Edge Weights II LCA / Binary Lifting O((n + q) log n)

Two Pointers
# Problem Pattern Complexity
11 Container With Most Water Opposite Ends Two Pointers O(n)
15 3Sum Sorting + Two Pointers O(n²)
16 3Sum Closest Sorting + Two Pointers O(n²)
18 4Sum Two Pointers / Sorting O(n^3)
26 Remove Duplicates from Sorted Array Slow / Fast Pointer O(n)
42 Trapping Rain Water Two Pointers + Left/Right Max O(n)
88 Merge Sorted Array Three Pointers (Backwards Merge) O(n)
125 Valid Palindrome Inward Two Pointers O(n)
167 Two Sum II Sorted Two Pointers O(n)
283 Move Zeroes Slow / Fast Pointer O(n)
344 Reverse String Opposite Ends Two Pointers O(n)
392 Is Subsequence Two Pointers / Greedy O(n)
977 Squares of a Sorted Array Opposite Ends Two Pointers O(n)
1855 Maximum Distance Between a Pair of Values Two Pointers O(n + m)
2540 Minimum Common Value Two Pointers O(n + m)
3756 Concatenate Non-Zero Digits and Multiply by Sum II Prefix Sum / Prefix Processing O(n + q)

SQL
Easy
ID Problem Topic Difficulty
181 Employees Earning More Than Their Managers Self JOIN Easy
182 Duplicate Emails GROUP BY / HAVING Easy
183 Customers Who Never Order LEFT JOIN Easy
196 Delete Duplicate Emails DELETE / SELF JOIN Easy
197 Rising Temperature SELF JOIN Easy
577 Employee Bonus LEFT JOIN / Filtering Easy
584 Find Customer Referee Filtering / NULL Handling Easy
586 Customer Placing the Largest Number of Orders SQL / GROUP BY / Aggregate Functions O(n)
595 Big Countries Filtering Easy
596 Classes With at Least 5 Students GROUP BY / HAVING Easy
607 Sales Person SQL / Subquery / JOIN / NOT IN Easy
610 Triangle Judgement CASE WHEN Easy
619 Biggest Single Number GROUP BY / HAVING Easy
620 Not Boring Movies Filtering / ORDER BY Easy
627 Swap Sex of Employees SQL / UPDATE / Conditional Function Easy
1050 Actors and Directors Who Cooperated At Least Three Times SQL / GROUP BY / HAVING Easy
1068 Product Sales Analysis I INNER JOIN Easy
1075 Project Employees I JOIN / GROUP BY / AVG Easy
1141 User Activity for the Past 30 Days I GROUP BY / COUNT DISTINCT Easy
1148 Article Views I Filtering / DISTINCT Easy
1211 Queries Quality and Percentage GROUP BY / Aggregation Easy
1251 Average Selling Price JOIN / Aggregation Easy
1280 Students and Examinations CROSS JOIN / LEFT JOIN / GROUP BY Easy
1327 List the Products Ordered in a Period JOIN / GROUP BY Easy
1378 Replace Employee ID With The Unique Identifier LEFT JOIN Easy
1407 Top Travellers SQL / LEFT JOIN / GROUP BY / Aggregate Functions Easy
1484 Group Sold Products By The Date GROUP BY / String Aggregation Easy
1517 Find Users With Valid E-Mails Regular Expressions Easy
1527 Patients With a Condition String Matching Easy
1581 Customer Who Visited but Did Not Make Any Transactions LEFT JOIN / GROUP BY Easy
1633 Percentage of Users Attended a Contest GROUP BY / Aggregation Easy
1661 Average Time of Process per Machine SELF JOIN / GROUP BY Easy
1667 Fix Names in a Table String Functions Easy
1683 Invalid Tweets String Functions / Filtering Easy
1693 Daily Leads and Partners SQL / GROUP BY / COUNT DISTINCT Easy
1729 Find Followers Count GROUP BY / COUNT Easy
1757 Recyclable and Low Fat Products Filtering Easy
1978 Employees Whose Manager Left the Company Subquery / Filtering Easy
2356 Number of Unique Subjects Taught by Each Teacher GROUP BY / COUNT DISTINCT Easy

Medium
ID Problem Topic Difficulty
176 Second Highest Salary Subquery / DISTINCT Medium
180 Consecutive Numbers SELF JOIN Medium
550 Game Play Analysis IV JOIN / Conditional Aggregation Medium
570 Managers with at Least 5 Direct Reports SELF JOIN / GROUP BY Medium
585 Investments in 2016 GROUP BY / Subquery Medium
602 Friend Requests II: Who Has the Most Friends UNION ALL / GROUP BY Medium
626 Exchange Seats CASE WHEN Medium
1045 Customers Who Bought All Products GROUP BY / HAVING / COUNT DISTINCT Medium
1070 Product Sales Analysis III GROUP BY / JOIN Medium
1164 Product Price at a Given Date GROUP BY / LEFT JOIN Medium
1174 Immediate Food Delivery II GROUP BY / Conditional Aggregation Medium
1193 Monthly Transactions I GROUP BY / Conditional Aggregation Medium
1204 Last Person to Fit in the Bus Window Function / Running Sum Medium
1321 Restaurant Growth Window Function / Rolling Average Medium
1341 Movie Rating JOIN / GROUP BY / Aggregation Medium
1731 The Number of Employees Which Report to Each Employee SELF JOIN / GROUP BY Medium
1789 Primary Department for Each Employee Filtering / GROUP BY Medium
1907 Count Salary Categories CASE WHEN / Aggregation Medium
1934 Confirmation Rate LEFT JOIN / GROUP BY / Conditional Aggregation Medium

Hard
ID Problem Topic Difficulty
185 Department Top Three Salaries Window Function / DENSE_RANK Hard

Pandas
ID Problem Topic Complexity
1873 Calculate Special Bonus Conditional Selection O(n)
2877 Create a DataFrame from List DataFrame Creation O(n)
2878 Get the Size of a DataFrame DataFrame Properties O(1)
2879 Display the First Three Rows DataFrame Selection O(1)
2880 Select Data DataFrame Selection O(1)
2881 Create a New Column Column Operations O(n)
2882 Drop Duplicate Rows Data Cleaning O(n)
2883 Drop Missing Data Data Cleaning O(n)
2884 Modify Columns Column Operations O(n)
2885 Rename Columns DataFrame Operations O(1)
2886 Change Data Type Data Type Conversion O(n)
2887 Fill Missing Data Missing Data Handling O(n)
2888 Reshape Data: Concatenate DataFrame Reshaping O(n + m)
2889 Reshape Data: Pivot DataFrame Reshaping O(n)
2890 Reshape Data: Melt DataFrame Reshaping O(n)
2891 Method Chaining Method Chaining O(n)

> PHILOSOPHY

"A mediocre solution you understand beats a perfect solution you copied."

The goal isn't to solve 500 problems blindly.
The goal is to see a new problem and know which pattern it belongs to — in under 30 seconds.


If this repo helped you, drop a ⭐ — it keeps the daily streak going.

This repository is updated daily as I grind pattern by pattern.

About

Daily DSA practice categorized by patterns with explanations and complexity analysis.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages