Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MonitSharma/LeetCode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2,424 Commits

Repository files navigation

-- Back to Homepage

Leetcode Solutions Repository

A curated collection of Leetcode problem solutions in multiple programming languages including Python, C, C++, Java, and JavaScript. Explore, learn, and contribute to this ever-growing repository.


Introduction

Leetcode is a popular platform for practicing algorithmic problems, ranging from beginner to expert levels. This repository contains solutions to over 500 problems, organized by difficulty and category, with detailed explanations and clean, well-documented code.


Features

  • 500+ Problems Solved: Solutions span various topics, including arrays, graphs, and dynamic programming.
  • Multi-language Support: Available in Python, C, C++, Java, and JavaScript.
  • Detailed Explanations: Each solution includes problem statements and step-by-step approaches.
  • Regular Updates: New problems and solutions are added consistently.
  • Open for Contributions: Join the community to enhance and expand this resource.

Solutions and Articles

You can explore the solutions in the table below. Each row includes:

  1. The problem number.
  2. The Leetcode problem title (linked to the problem page).
  3. A link to the corresponding Medium article for an in-depth explanation.
Problem number Leetcode Problem Medium Article
4 Median of Two Sorted Arrays
5 Longest Palindromic Substring
17 Letter Combinations of Phone Number
24 Swap Nodes in Pairs
33 Search in Rotated Sorted Array
34 Find First and Last Position of Element in Sorted Array
46 Permutations
50 Pow(x,n)
54 Spiral Matrix
59 Spiral Matrix II
63 Unique Paths II
68 Text Justification
71 Simplifying Path
74 Search a 2D Matrix
77 Combinations
81 Search in Rotated Sorted Array II
86 Partition List
92 Reverse Linked List II
95 Unique Binary Search Trees II
97 Interleaving Strings
111 Minimum Depth of a Binary Tree
118 Pascal's Triangle
119 Pascal's Triangle II
135 Candy
137 Single Number II
138 Copy list with Random Pointer
139 Word break
141 Linked List Cycle
146 LRU Cache
168 Excel Sheet Column Title
207 Course Schedule
209 Minimum Size Subarray Sum
215 Kth Largest element in an array
225 Implement Stack using Queues
228 Summary Ranges
239 Sliding Window Maximum
258 Add Digits
287 Find the Duplicate Number
316 Remove Duplicate Letters
319 Bulb Switcher
332 Reconstruct Itinerary
338 Counting Bits
341 Flatten Nested List Iterator
342 Power of Four
343 Integer Break
347 Top K Frequent Elements
373 Find K Pairs with Smallest Sums
389 Find the Difference
392 Is Subsequence
399 Evaluate Division
403 Frog Jump
435 Non Overlapping Intervals
445 Add two numbers II
459 Repeated Substring Patterns
486 Predict the Winner
501 Find Mode in Binary Search Tree
515 Find Largest Value in Each Tree Row
516 Longest Palindromic Subsequence
518 Coin Change II
530 Minimum Absolute Difference in BST
542 01 Matrix
547 Number of Provinices
646 Maximum Length of a Pair Chain
649 Dota2 Senate
662 Maximum Width of Binary Tree
664 Maximum Width of Binary Tree
673 Number of Longest Increasing Sub-sequences
688 Knight Probability in Chessboard
703 Kth Largest element in a stream
705 Design Hashset
706 Design Hashmap
712 Minimum ASCII Delete Sum for Two Strings
714 Best Time to Buy and Sell Stock with Transaction Fee
725 Split Linked List in Parts
735 Asteroid Collision
744 Find samllest letter greater than target
746 Min Cost Climbing Stairs
758 Is Graph Bipartite?
767 Reorganize String
779 K-th Symbol in Grammar
802 Find Eventual Safe States
808 Soup Servings
823 Binary Tree with Factors
837 New 21 Game
839 Similar String Groups
844 Backspace String Compare
852 Peak Index in a Mountain Array
859 Buddy Strings
863 All Nodes Distance K in Binary Tree
864 Shortest Path to Get All Keys
879 Profitable Schemes
880 Decoded String at Index
894 All Possible Full Binary Trees
896 Monotonic Array
920 Number of Music Playlist
934 Shortest Bridge
946 Validate Stack Sequences
956 Tallest Billboard
1027 Longest Arithmetic Subsequence
1035 Uncrossed Lines
1046 Last Stone Weight
1091 Shortest Path in Binary Matrix
1095 Find in Mountain Array
1125 Smallest Sufficient Team
1140 Stone Game II
1146 Snapshot Array
1161 Maximum Level Sum of a Binary Tree
1187 Make Array Strictly Increasing
1203 Sort Items by Groups Respecting Dependencies
1218 Longest Arithmetic Subsequence of Given Difference
1232 Check If It Is a Straight Line
1282 Group the People Given the Group Size They Belong To
1312 Minimum Insertion Steps to Make a String Palindrome
1318 Minimum Flips to Make a OR b Equal to c
1326 Minimum Number of Taps to Open to Water a Garden
1337 The K Weakest Rows in a Matrix
1351 Count Negative Numbers in a Sorted Matrix
1361 Validate Binary Tree Nodes
1372 Longest ZigZag Path in a Binary Tree
1376 Time needed to inform all employees
1396 Design Underground System
1406 Stone Game III
1416 Restore The Array
1422 Maximum Score After Splitting a String
1431 Kids With the Greatest Number of Candies
1456 Maximum Number of Vowels in a Substring of Given Length
1489 Find Critical and Pseudo Critical Edges in Minimum Spanning Tree
1491 Average Salary Excluding the Minimum and Maximum Salary
1493 Longest Subarray of 1's After Deleting One Element
1498 Number of Subsequences That Satisfy the Given Sum Condition
1502 Can Make Arithemetic Progressions from a Sequence
1512 Number of Good Pairs
1514 Path with Maximum Probability
1547 Minimum Cost to cut a stick
1569 Number of Ways to Reorder Array to Get Same BST
1572 Matrix Diagonal Sum
1575 Count All Possible Routes
1577 Maximum number of vertices to Reach all nodes
1579 Remove Max Number of Edges to Keep Graph Fully Traversable
1584 Min Cost to Connect All Points
1601 Maximum Number of Achievable Transfer Requests
1603 Design Parking System
1615 Maximal Network Rank
1639 Number of Ways to Form a Target String Given a Dictionary
1647 Minimum Deletions to Make Character Frequencies Unique
1658 Minimum Operations to Reduce X to Zero
1697 Checking the Existence of Edge Length Limited Paths
1721 Swapping Nodes in a Linked List
1732 Find the highest Altitude
1751 Maximum Number of Events That Can Be Attended II
1768 Merge Strings Alternately
1799 Maximize score after N Operations
1802 Maximum Value at a Given Index in a Bounded Array
1822 Sign of the Product of an Array
1870 Minimum Speed to Arrive on Time
1964 Find the Longest Valid Obstacle Course at Each Position
1970 Last Day Where You Can Still Cross
2009 Minimum Number of Operations to Make Array Continuous
2022 Convert 1D Array Into 2D Array
2028 Find Missing Observation
2024 Maximize the confusion of an Exam
2038 Remove Colored Pieces if Both Neighbors are the same color
2050 Parallel Courses III
2090 K Radius Subarray Averages
2101 Detonate the Maximum Bombs
2116 Check if a Parantheses String Can Be a Valid
2130 Maximum Twin sum of a Linked List
2140 Solving Questions with Brainpower
2141 Maximum Running time for N Computers
2215 Find the Difference of Two Arrays
2218 Maximum Value of K Coins From Piles
2251 Number of Flowers in Full Bloom
2272 Substring With Largest Variance
2305 Fair Distribution of Cookies
2328 Number of Increasing Paths in a Grid
2336 Smallest Number in Infinite Set
2352 Equal Row and Column Pairs
2366 Minimum Replacements to Sort the Array
2369 Check if there is a Valid Partition For The Array
2433 Find The Original Array of Prefix Xor
2448 Minimum Cost to Make Array Equal
2462 Total Cost to Hire K Workers
2466 Count Ways To Build Good Strings
2483 Minimum Penalty for a shop
2542 Maximum Subsequence Score
2551 Put Marbles in Bags
2616 Minimize the Maximum difference in pairs
2707 Extra Characters in a String

Usage

This repository can serve multiple purposes:

  1. Reference: Find solutions to Leetcode problems with clean, readable code.
  2. Learning: Understand new problem-solving approaches and algorithmic techniques.
  3. Contribution: Collaborate to expand the repository with new solutions.

Contributing

Contributions are always welcome! Add new solutions, improve existing code, or enhance documentation. Before contributing, read the Contribution Guidelines.


License

This repository is licensed under the MIT License. Feel free to use, modify, and distribute the content as per the license terms.


Current Stats

  • Rank: 83,730
  • Total Problems Solved: 500+

Stay Updated

New solutions are added daily. Check back regularly for updates and stay connected!


About

Current Problems Solved : 552 ; Current Leet Code rank : 88,322

Topics

Resources

Readme

License

MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages