Merge Sort LeetCode Problems: All 11, With Python Solutions

Every problem in this library that LeetCode tags Merge Sort 11 in total, 9 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 11 problems
  • 0 Easy
  • 3 Medium
  • 8 Hard

How Merge Sort problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Merge Sort problems — each one explains the approach, gives a Python template and states its complexity.

  • Sorting — Spend O(n log n) once to buy an ordering that makes the rest of the problem trivial.

Merge Sort problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Medium (3)

#ProblemDifficultyTopics
148Sort ListMediumLinked List, Two Pointers, Divide and Conquer +2
912Sort an ArrayMediumArray, Divide and Conquer, Bucket Sort +5
2031Count Subarrays With More Ones Than ZerosPremiumMediumBinary Indexed Tree, Segment Tree, Array +5

Hard (8)

#ProblemDifficultyTopics
23Merge k Sorted ListsHardLinked List, Divide and Conquer, Heap (Priority Queue) +1
315Count of Smaller Numbers After SelfHardBinary Indexed Tree, Segment Tree, Array +4
327Count of Range SumHardBinary Indexed Tree, Segment Tree, Array +4
493Reverse PairsHardBinary Indexed Tree, Segment Tree, Array +4
1649Create Sorted Array through InstructionsHardBinary Indexed Tree, Segment Tree, Array +4
2179Count Good Triplets in an ArrayHardBinary Indexed Tree, Segment Tree, Array +4
2426Number of Pairs Satisfying InequalityHardBinary Indexed Tree, Segment Tree, Array +4
2519Count the Number of K-Big IndicesPremiumHardBinary Indexed Tree, Segment Tree, Array +4

When the Merge Sort problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.