Backend Developer
Sorting and binary search questions
145 questions on Sorting and binary search for backend developers, easiest first.
Easy 39
- Precondition for binary searcheasy
- Safe midpoint in binary searcheasy
- Anagram check by sortingeasy
- Steps to find a value by binary searcheasy
- Bubble sort best case with early exiteasy
- What a stable sort meanseasy
- Merge sort time in every caseeasy
- Best simple sort for nearly sorted dataeasy
- Swaps made by selection sorteasy
- What in-place sorting meanseasy
- Quick sort worst-case timeeasy
- JavaScript default sort on numberseasy
- Comparator sign for ascending ordereasy
- When counting sort is a good fiteasy
- Python sorted() versus list.sort()easy
- Lower bound for comparison sortingeasy
- Extra memory used by merge sorteasy
- Is heap sort stable?easy
- Trace one bubble sort passeasy
- Best case of binary searcheasy
- Time complexity of binary searcheasy
- Binary search steps for a million itemseasy
- Overflow-safe midpoint formulaeasy
- Loop condition for a closed search rangeeasy
- Trace a binary searcheasy
- One search in unsorted dataeasy
- What bisect_left returnseasy
- Java Arrays.binarySearch when not foundeasy
- What C++ lower_bound returnseasy
- Binary search on a sorted linked listeasy
- Range size after several halvingseasy
- Space used by recursive binary searcheasy
- Which duplicate a plain search findseasy
- The three steps of divide and conquereasy
- Solving T(n) = 2T(n/2) + neasy
- Solving T(n) = T(n/2) + 1easy
- Fast exponentiation by squaringeasy
- Solving T(n) = T(n - 1) + neasy
- Grouping anagrams with a sorted keyeasy
Medium 62
- Sort 0s, 1s and 2s in one passmedium
- First position of a repeated valuemedium
- Binary search in a rotated arraymedium
- Minimum of a rotated sorted arraymedium
- Binary search a matrix as one arraymedium
- What the O(n log n) LIS array holdsmedium
- Sort characters by frequencymedium
- Ranking products by salesmedium
- Key-value store with timestampsmedium
- Insertion sort shifts on a reversed arraymedium
- Trace a Lomuto partitionmedium
- Why quick sort uses a random pivotmedium
- Algorithm behind Python and V8 sortmedium
- Is JavaScript Array sort stable?medium
- Time complexity of LSD radix sortmedium
- Sorting by two keys with stable sortsmedium
- Comparator that returns a booleanmedium
- Comparisons needed to merge two listsmedium
- Merge sort recursion depth for 1024 itemsmedium
- Keeping quick sort stack depth lowmedium
- Heap type used for ascending heap sortmedium
- Main idea behind Shell sortmedium
- Bucket sort for uniform valuesmedium
- Sorting a file bigger than memorymedium
- Quick sort with many equal keysmedium
- Sort an array of 0s, 1s and 2smedium
- Why radix sort needs a stable inner sortmedium
- Sorting customer names correctlymedium
- Where NULLs go in PostgreSQL ORDER BYmedium
- Sorting dates stored as DD/MM/YYYY textmedium
- Finding the first occurrencemedium
- Counting a value with two boundsmedium
- Searching a rotated sorted arraymedium
- Single value among pairs in a sorted arraymedium
- Integer square root by binary searchmedium
- Minimum truck capacity in D daysmedium
- Condition for binary search on the answermedium
- Finding a peak with binary searchmedium
- Search insert positionmedium
- Searching a list of unknown lengthmedium
- Binary search a fully sorted matrixmedium
- Search a row- and column-sorted matrixmedium
- Steps git bisect needsmedium
- Cost of inserting into a sorted arraymedium
- When interpolation search winsmedium
- Ternary search on a unimodal functionmedium
- Find k closest values in a sorted arraymedium
- First log entry after a timestampmedium
- lower_bound past the endmedium
- Calls needed to find the first bad versionmedium
- upper_bound on duplicate valuesmedium
- Counting values up to X in a sorted arraymedium
- Slowest speed to finish within H hoursmedium
- Solving T(n) = 2T(n/2) + 1medium
- Solving T(n) = 4T(n/2) + nmedium
- Running time of quickselectmedium
- Counting inversions with merge sortmedium
- Maximum subarray by divide and conquermedium
- Merging k sorted lists in pairsmedium
- Pair sum with sorting and two pointersmedium
- Merging overlapping intervalsmedium
- Second largest with quickselectmedium
Hard 44
- Median of two sorted arrayshard
- Sorting a file larger than memoryhard
- Dutch flag: when mid must not advancehard
- Minimum eating speed by binary searchhard
- Least ship capacity for a deadlinehard
- Binary search that never endshard
- Search a matrix sorted by rows and columnshard
- Sorting file names with numbershard
- Counting inversionshard
- Largest number from concatenationhard
- Sorting by two keys with a stable sorthard
- How introsort avoids quick sort's worst casehard
- C++ sort versus stable_sorthard
- Lomuto quick sort on all-equal keyshard
- Best algorithm to sort a linked listhard
- Insertion sort comparisons on reversed inputhard
- Minimum swaps to sort a permutationhard
- Radix sort versus a comparison sorthard
- Sorting software version numbershard
- Timsort on already sorted datahard
- Bug from sorting with an unstable sorthard
- Rows missing across paginated pageshard
- Default sort of a Float64Arrayhard
- Largest number formed from an arrayhard
- Why selection sort is not stablehard
- Binary search loop that never endshard
- Bit-shift midpoint in JavaScripthard
- Binary search over real numbershard
- k-th smallest pair distancehard
- k-th smallest in a sorted matrixhard
- Split an array to minimise the largest sumhard
- Rotated array search with duplicateshard
- Duplicate number by counting valueshard
- Half-open binary search boundshard
- Sorted array or hash map for lookupshard
- Place items to maximise the minimum gaphard
- Search in a bitonic arrayhard
- How many times a sorted array was rotatedhard
- Why Karatsuba beats school multiplicationhard
- Median of medians pivot selectionhard
- Closest pair of points in O(n log n)hard
- Strassen matrix multiplicationhard
- Insertion sort cutoff in fast sortshard
- Sorting data across many machineshard