Sorting

Sort the data, or a key built from each item, so related items end up side by side or in a known order. Look for grouping, ranking or comparing frequencies, as in Group Anagrams. Once sorted, many problems need only a simple scan.

15 problems · 6 with a video · 3 to practice in an AI round

Sorting problems
#ProblemDifficultyVideoAI round
1Group AnagramsMediumAI round
2Valid AnagramEasy
3Contains DuplicateEasyAI round
4Majority Element IIMedium—
5Find All Duplicates in an ArrayMedium
6How Many Numbers Are Smaller Than the Current NumberVery easy
7Determine if Two Strings Are CloseMedium—
8Sort Array by Increasing FrequencyVery easy—
9Third Maximum NumberEasy—
10Maximum GapMedium—AI round
11Minimum Absolute DifferenceEasy—
12Rank Transform of an ArrayVery easy—
13Sorting the SentenceVery easy
14Can Make Arithmetic Progression From SequenceEasy—
15Rank Teams by VotesMedium—

Practice in an AI round

Three of these are AI rounds: 30 minutes, an AI agent beside your code, then a scored report.

Practice Group Anagrams in an AI round