Sorting | LeetCode Problems

308 Sorting solutions to LeetCode solutions.

Sorting Problems View all solutions →

3Sum

#15 Medium

3Sum Closest

#16 Medium

4Sum

#18 Medium

Permutations II

#47 Medium

Group Anagrams

#49 Medium

Merge Intervals

#56 Medium

Sort Colors

#75 Medium

Merge Sorted Array

#88 Easy

Insertion Sort List

#147 Medium

Sort List

#148 Medium

Maximum Gap

#164 Medium

Majority Element

#169 Easy

Largest Number

#179 Medium

Kth Largest Element in an Array

#215 Medium

Contains Duplicate

#217 Easy

Contains Duplicate III

#220 Hard

Majority Element II

#229 Medium

Valid Anagram

#242 Easy

Missing Number

#268 Easy

H-Index

#274 Medium

Find Median from Data Stream

#295 Hard

Wiggle Sort II

#324 Medium

Top K Frequent Elements

#347 Medium

Intersection of Two Arrays

#349 Easy

Intersection of Two Arrays II

#350 Easy

Russian Doll Envelopes

#354 Hard

Largest Divisible Subset

#368 Medium

Kth Smallest Element in a Sorted Matrix

#378 Medium

Find the Difference

#389 Easy

Queue Reconstruction by Height

#406 Medium

Third Maximum Number

#414 Easy

Non-overlapping Intervals

#435 Medium

Find Right Interval

#436 Medium

Sort Characters By Frequency

#451 Medium

Minimum Number of Arrows to Burst Balloons

#452 Medium

Assign Cookies

#455 Easy

Minimum Moves to Equal Array Elements II

#462 Medium

Heaters

#475 Medium

IPO

#502 Hard

Relative Ranks

#506 Easy

Longest Uncommon Subsequence II

#522 Medium

Longest Word in Dictionary through Deleting

#524 Medium

K-diff Pairs in an Array

#532 Medium

Minimum Time Difference

#539 Medium

Array Partition

#561 Easy

Shortest Unsorted Continuous Subarray

#581 Medium

Longest Harmonious Subsequence

#594 Easy

Valid Triangle Number

#611 Medium

Task Scheduler

#621 Medium

Maximum Product of Three Numbers

#628 Easy

Course Schedule III

#630 Hard

Smallest Range Covering Elements from K Lists

#632 Hard

Set Mismatch

#645 Medium

Maximum Length of Pair Chain

#646 Medium

Find K Closest Elements

#658 Medium

Top K Frequent Words

#692 Medium

Random Pick with Blacklist

#710 Hard

Find K-th Smallest Pair Distance

#719 Hard

Longest Word in Dictionary

#720 Medium

Accounts Merge

#721 Medium

Number of Atoms

#726 Hard

Largest Number At Least Twice of Others

#747 Easy

Set Intersection Size At Least Two

#757 Hard

Reorganize String

#767 Medium

Max Chunks To Make Sorted II

#768 Hard

Max Chunks To Make Sorted

#769 Medium

K-th Smallest Prime Fraction

#786 Medium

Custom Sort String

#791 Medium

Number of Matching Subsequences

#792 Medium

Binary Trees With Factors

#823 Medium

Friends Of Appropriate Ages

#825 Medium

Most Profit Assigning Work

#826 Medium

Find And Replace in String

#833 Medium

Hand of Straights

#846 Medium

Car Fleet

#853 Medium

Minimum Cost to Hire K Workers

#857 Hard

Reordered Power of 2

#869 Medium

Advantage Shuffle

#870 Medium

Boats to Save People

#881 Medium

Fair Candy Swap

#888 Easy

Sum of Subsequence Widths

#891 Hard

Groups of Special-Equivalent Strings

#893 Medium

Orderly Queue

#899 Hard

Sort Array By Parity

#905 Easy

Smallest Range II

#910 Medium

Sort an Array

#912 Medium

Sort Array By Parity II

#922 Easy

3Sum With Multiplicity

#923 Medium

Reorder Data in Log Files

#937 Medium

Minimum Area Rectangle

#939 Medium

Minimum Increment to Make Array Unique

#945 Medium

Bag of Tokens

#948 Medium

Reveal Cards In Increasing Order

#950 Medium

Array of Doubled Pairs

#954 Medium

Pancake Sorting

#969 Medium

K Closest Points to Origin

#973 Medium

Largest Perimeter Triangle

#976 Easy

Squares of a Sorted Array

#977 Easy

Vertical Order Traversal of a Binary Tree

#987 Hard

Maximize Sum Of Array After K Negations

#1005 Easy

Two City Scheduling

#1029 Medium

Matrix Cells in Distance Order

#1030 Easy

Moving Stones Until Consecutive II

#1040 Medium

Longest String Chain

#1048 Medium

Height Checker

#1051 Easy

Distant Barcodes

#1054 Medium

Largest Values From Labels

#1090 Medium

Car Pooling

#1094 Medium

Relative Sort Array

#1122 Easy

Invalid Transactions

#1169 Medium

Compare Strings by Frequency of the Smallest Character

#1170 Medium

Make Array Strictly Increasing

#1187 Hard

Minimum Absolute Difference

#1200 Easy

Smallest String With Swaps

#1202 Medium

Maximum Profit in Job Scheduling

#1235 Hard

Greatest Sum Divisible by Three

#1262 Medium

Search Suggestions System

#1268 Medium

Remove Covered Intervals

#1288 Medium

Divide Array in Sets of K Consecutive Numbers

#1296 Medium

Sum of Mutated Array Closest to Target

#1300 Medium

All Elements in Two Binary Search Trees

#1305 Medium

Get Watched Videos by Your Friends

#1311 Medium

Sort the Matrix Diagonally

#1329 Medium

Rank Transform of an Array

#1331 Easy

Filter Restaurants by Vegan-Friendly, Price and Distance

#1333 Medium

The K Weakest Rows in a Matrix

#1337 Easy

Reduce Array Size to The Half

#1338 Medium

Jump Game V

#1340 Hard

Check If N and Its Double Exist

#1346 Easy

Tweet Counts Per Frequency

#1348 Medium

Maximum Number of Events That Can Be Attended

#1353 Medium

Sort Integers by The Number of 1 Bits

#1356 Easy

Largest Multiple of Three

#1363 Hard

How Many Numbers Are Smaller Than the Current Number

#1365 Easy

Rank Teams by Votes

#1366 Medium

Maximum Performance of a Team

#1383 Hard

Find the Distance Value Between Two Arrays

#1385 Easy

Sort Integers by The Power Value

#1387 Medium

Reducing Dishes

#1402 Hard

Minimum Subsequence in Non-Increasing Order

#1403 Easy

Display Table of Food Orders in a Restaurant

#1418 Medium

Diagonal Traverse II

#1424 Medium

Check If a String Can Break Another String

#1433 Medium

Rearrange Words in a Sentence

#1451 Medium

Make Two Arrays Equal by Reversing Sub-arrays

#1460 Easy

Maximum Product of Two Elements in an Array

#1464 Easy

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

#1465 Medium

The k Strongest Values in an Array

#1471 Medium

Allocate Mailboxes

#1478 Hard

Least Number of Unique Integers after K Removals

#1481 Medium

Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree

#1489 Hard

Average Salary Excluding the Minimum and Maximum Salary

#1491 Easy

Number of Subsequences That Satisfy the Given Sum Condition

#1498 Medium

Can Make Arithmetic Progression From Sequence

#1502 Easy

Range Sum of Sorted Subarray Sums

#1508 Medium

Minimum Difference Between Largest and Smallest Value in Three Moves

#1509 Medium

Minimum Cost to Cut a Stick

#1547 Hard

Magnetic Force Between Two Balls

#1552 Medium

Maximum Number of Coins You Can Get

#1561 Medium

Check If String Is Transformable With Substring Sort Operations

#1585 Hard

Maximum Sum Obtained of Any Permutation

#1589 Medium

Alert Using Same Key-Card Three or More Times in a One Hour Period

#1604 Medium

Special Array With X Elements Greater Than or Equal X

#1608 Easy

Maximum Number of Visible Points

#1610 Hard

Mean of Array After Removing Some Elements

#1619 Easy

Best Team With No Conflicts

#1626 Medium

Arithmetic Subarrays

#1630 Medium

Rank Transform of a Matrix

#1632 Hard

Sort Array by Increasing Frequency

#1636 Easy

Widest Vertical Area Between Two Points Containing No Points

#1637 Easy

Minimum Deletions to Make Character Frequencies Unique

#1647 Medium

Sell Diminishing-Valued Colored Balls

#1648 Medium

Determine if Two Strings Are Close

#1657 Medium

Minimum Initial Energy to Finish Tasks

#1665 Hard

Max Number of K-Sum Pairs

#1679 Medium

Stone Game VI

#1686 Medium

Maximum Height by Stacking Cuboids

#1691 Hard

Checking Existence of Edge Length Limited Paths

#1697 Hard

Maximum Units on a Truck

#1710 Easy

Largest Submatrix With Rearrangements

#1727 Medium

Find Kth Largest XOR Coordinate Value

#1738 Medium

Maximum Number of Events That Can Be Attended II

#1751 Hard

Closest Subsequence Sum

#1755 Hard

Count Pairs Of Nodes

#1782 Hard

Maximum Number of Consecutive Values You Can Make

#1798 Medium

Minimum Absolute Sum Difference

#1818 Medium

Maximum Ice Cream Bars

#1833 Medium

Single-Threaded CPU

#1834 Medium

Frequency of the Most Frequent Element

#1838 Medium

Maximum Building Height

#1840 Hard

Maximum Element After Decreasing and Rearranging

#1846 Medium

Closest Room

#1847 Hard

Minimum Interval to Include Each Query

#1851 Hard

Sorting the Sentence

#1859 Easy

Minimize Maximum Pair Sum in Array

#1877 Medium

Get Biggest Three Rhombus Sums in a Grid

#1878 Medium

Reduction Operations to Make the Array Elements Equal

#1887 Medium

Minimum Space Wasted From Packaging

#1889 Hard

Maximum Product Difference Between Two Pairs

#1913 Easy

Eliminate Maximum Number of Monsters

#1921 Medium

Describe the Painting

#1943 Medium

Array With Elements Not Equal to Average of Neighbors

#1968 Medium

Minimum Difference Between Highest and Lowest of K Scores

#1984 Easy

Find the Kth Largest Integer in the Array

#1985 Medium

The Number of Weak Characters in the Game

#1996 Medium

GCD Sort of an Array

#1998 Hard

Find Original Array From Doubled Array

#2007 Medium

Maximum Earnings From Taxi

#2008 Medium

Minimum Operations to Make a Uni-Value Grid

#2033 Medium

Minimum Number of Moves to Seat Everyone

#2037 Easy

Most Beautiful Item for Each Query

#2070 Medium

Maximum Number of Tasks You Can Assign

#2071 Hard

Find Target Indices After Sorting Array

#2089 Easy

Find All People With Secret

#2092 Hard

Finding 3-Digit Even Numbers

#2094 Easy

Find Subsequence of Length K With the Largest Sum

#2099 Medium

Recover the Original Array

#2122 Hard

Destroying Asteroids

#2126 Medium

Count Words Obtained After Adding a Letter

#2135 Medium

Earliest Possible Day of Full Bloom

#2136 Hard

Maximum Running Time of N Computers

#2141 Hard

Minimum Cost of Buying Candies With Discount

#2144 Easy

Count Elements With Strictly Smaller and Greater Elements

#2148 Easy

Keep Multiplying Found Values by Two

#2154 Easy

Minimum Sum of Four Digit Number After Splitting Digits

#2160 Easy

Sort Even and Odd Indices Independently

#2164 Easy

Smallest Value of the Rearranged Number

#2165 Medium

Removing Minimum Number of Magic Beans

#2171 Medium

Sort the Jumbled Numbers

#2191 Medium

Append K Integers With Minimal Sum

#2195 Medium

Find Players With Zero or One Losses

#2225 Medium

Maximum Total Beauty of the Gardens

#2234 Hard

Maximum Score of a Node Sequence

#2242 Hard

Intersection of Multiple Arrays

#2248 Easy

Count Number of Rectangles Containing Each Point

#2250 Medium

Number of Flowers in Full Bloom

#2251 Hard

Maximum White Tiles Covered by a Carpet

#2271 Medium

Find Resultant Array After Removing Anagrams

#2273 Easy

Maximum Consecutive Floors Without Special Floors

#2274 Medium

Maximum Bags With Full Capacity of Rocks

#2279 Medium

Minimum Lines to Represent a Line Chart

#2280 Medium

Partition Array Such That Maximum Difference Is K

#2294 Medium

Successful Pairs of Spells and Potions

#2300 Medium

Max Sum of a Pair With Equal Sum of Digits

#2342 Medium

Merge Similar Items

#2363 Easy

Longest Subsequence With Limited Sum

#2389 Easy

Maximum Matching of Players With Trainers

#2410 Medium

Minimum Money Required Before Transactions

#2412 Hard

Sort the People

#2418 Easy

Number of Good Paths

#2421 Hard

Largest Positive Integer That Exists With Its Negative

#2441 Easy

Minimum Cost to Make Array Equal

#2448 Hard

Minimum Number of Operations to Make Arrays Similar

#2449 Hard

Minimum Total Distance Traveled

#2463 Hard

Number of Distinct Averages

#2465 Easy

Number of Unequal Triplets in Array

#2475 Easy

Divide Players Into Teams of Equal Skill

#2491 Medium

Longest Square Streak in an Array

#2501 Medium

Maximum Number of Points From Grid Queries

#2503 Hard

Maximum Tastiness of Candy Basket

#2517 Medium

Maximum Subsequence Score

#2542 Medium

Sort the Students by Their Kth Score

#2545 Medium

Put Marbles in Bags

#2551 Hard

Maximum Number of Integers to Choose From a Range I

#2554 Medium

Count the Number of Fair Pairs

#2563 Medium

Minimum Score by Changing Two Elements

#2567 Medium

Find the Maximum Number of Marked Indices

#2576 Medium

Split With Minimum Sum

#2578 Easy

Kth Largest Sum in a Binary Tree

#2583 Medium

Rearrange Array to Maximize Prefix Score

#2587 Medium

Maximize Greatness of an Array

#2592 Medium

The Number of Beautiful Subsets

#2597 Medium

Buy Two Chocolates

#2706 Easy

Neither Minimum nor Maximum

#2733 Easy

Find the Value of the Partition

#2740 Medium

Robot Collisions

#2751 Hard

Relocate Marbles

#2766 Medium

Maximum Beauty of an Array After Applying Operation

#2779 Medium

Minimum Index of a Valid Split

#2780 Medium

Check if Array is Good

#2784 Easy

Sort Vowels in a String

#2785 Medium

Apply Operations to Maximize Score

#2818 Hard

Count Pairs Whose Sum is Less than Target

#2824 Easy

Check if Strings Can be Made Equal With Operations II

#2840 Medium

Happy Students

#2860 Medium

Minimum Processing Time

#2895 Medium

High-Access Employees

#2933 Medium

Make Lexicographically Smallest Array by Swapping Elements

#2948 Medium

Minimum Number of Coins to be Added

#2952 Medium

Divide Array Into Arrays With Max Difference

#2966 Medium

Find Polygon With the Largest Perimeter

#2971 Medium

Divide an Array Into Subarrays With Minimum Cost I

#3010 Easy

Find if Array Can Be Sorted

#3011 Medium

Minimum Number of Pushes to Type Word II

#3016 Medium

Type of Triangle

#3024 Easy

Find the Number of Ways to Place People I

#3025 Medium

Find the Number of Ways to Place People II

#3027 Hard

Maximum Palindromes After Operations

#3035 Medium

Apply Operations to Make String Empty

#3039 Medium

Find the Maximum Sum of Node Values

#3068 Hard

Apple Redistribution into Boxes

#3074 Easy

Maximize Happiness of Selected Children

#3075 Medium

Minimum Deletions to Make String K-Special

#3085 Medium

Count Days Without Meetings

#3169 Medium

Zero Array Transformation III

#3362 Medium

Check if Grid can be Cut into Sections

#3394 Medium

Maximum Number of Distinct Elements After Operations

#3397 Medium

Maximum Sum With at Most K Elements

#3462 Medium