Sorting | LeetCode Problems

224 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

Minimum Operations to Make a Uni-Value Grid

#2033 Medium

Minimum Number of Moves to Seat Everyone

#2037 Easy

Maximum Number of Tasks You Can Assign

#2071 Hard

Find Subsequence of Length K With the Largest Sum

#2099 Medium

Keep Multiplying Found Values by Two

#2154 Easy

Successful Pairs of Spells and Potions

#2300 Medium

Max Sum of a Pair With Equal Sum of Digits

#2342 Medium

Maximum Number of Points From Grid Queries

#2503 Hard

Maximum Subsequence Score

#2542 Medium

Put Marbles in Bags

#2551 Hard

Count the Number of Fair Pairs

#2563 Medium

Minimum Index of a Valid Split

#2780 Medium

Apply Operations to Maximize Score

#2818 Hard

Make Lexicographically Smallest Array by Swapping Elements

#2948 Medium

Count Days Without Meetings

#3169 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