Medium LeetCode Problems: All 1,579,
With Python Solutions

Medium is where most interview questions actually sit. The technique is no longer stated — recognising which pattern applies is the problem, and the implementation is the easy half once you have.

The rating is LeetCode's own, carried through unchanged.

With a full solution
1,191
LeetCode Premium
358
Patterns
22

Eyes only

A medium problem, live, with someone watching.

In the live round, Stealth Interview reads the 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 says. It's a desktop app for macOS and Windows, invisible to screen sharing.

Page 1 of 8

Medium problems

Showing the first 200 of 1,579 problems. Problems with a complete Python solution are listed first, then by ascending problem number.

Medium problems
No.Problem
0002Add Two Numbers
0003Longest Substring Without Repeating Characters
0005Longest Palindromic Substring
0006Zigzag Conversion
0007Reverse Integer
0008String to Integer (atoi)
0011Container With Most Water
0012Integer to Roman
00153Sum
00163Sum Closest
0017Letter Combinations of a Phone Number
00184Sum
0019Remove Nth Node From End of List
0022Generate Parentheses
0024Swap Nodes in Pairs
0029Divide Two Integers
0031Next Permutation
0033Search in Rotated Sorted Array
0034Find First and Last Position of Element in Sorted Array
0036Valid Sudoku
0038Count and Say
0039Combination Sum
0040Combination Sum II
0043Multiply Strings
0045Jump Game II
0046Permutations
0047Permutations II
0048Rotate Image
0049Group Anagrams
0050Pow(x, n)
0053Maximum Subarray
0054Spiral Matrix
0055Jump Game
0056Merge Intervals
0057Insert Interval
0059Spiral Matrix II
0061Rotate List
0062Unique Paths
0063Unique Paths II
0064Minimum Path Sum
0071Simplify Path
0072Edit Distance
0073Set Matrix Zeroes
0074Search a 2D Matrix
0075Sort Colors
0077Combinations
0078Subsets
0079Word Search
0080Remove Duplicates from Sorted Array II
0081Search in Rotated Sorted Array II
0082Remove Duplicates from Sorted List II
0086Partition List
0089Gray Code
0090Subsets II
0091Decode Ways
0092Reverse Linked List II
0093Restore IP Addresses
0095Unique Binary Search Trees II
0096Unique Binary Search Trees
0097Interleaving String
0098Validate Binary Search Tree
0099Recover Binary Search Tree
0102Binary Tree Level Order Traversal
0103Binary Tree Zigzag Level Order Traversal
0105Construct Binary Tree from Preorder and Inorder Traversal
0106Construct Binary Tree from Inorder and Postorder Traversal
0107Binary Tree Level Order Traversal II
0109Convert Sorted List to Binary Search Tree
0113Path Sum II
0114Flatten Binary Tree to Linked List
0116Populating Next Right Pointers in Each Node
0117Populating Next Right Pointers in Each Node II
0120Triangle
0122Best Time to Buy and Sell Stock II
0128Longest Consecutive Sequence
0129Sum Root to Leaf Numbers
0130Surrounded Regions
0131Palindrome Partitioning
0133Clone Graph
0134Gas Station
0137Single Number II
0138Copy List with Random Pointer
0139Word Break
0142Linked List Cycle II
0143Reorder List
0146LRU Cache
0147Insertion Sort List
0148Sort List
0150Evaluate Reverse Polish Notation
0151Reverse Words in a String
0152Maximum Product Subarray
0153Find Minimum in Rotated Sorted Array
0155Min Stack
0162Find Peak Element
0164Maximum Gap
0165Compare Version Numbers
0166Fraction to Recurring Decimal
0167Two Sum II - Input Array Is Sorted
0172Factorial Trailing Zeroes
0173Binary Search Tree Iterator
0176Second Highest Salary
0177Nth Highest Salary
0178Rank Scores
0179Largest Number
0180Consecutive Numbers
0184Department Highest Salary
0187Repeated DNA Sequences
0189Rotate Array
0192Word Frequency
0194Transpose File
0198House Robber
0199Binary Tree Right Side View
0200Number of Islands
0201Bitwise AND of Numbers Range
0204Count Primes
0207Course Schedule
0208Implement Trie (Prefix Tree)
0209Minimum Size Subarray Sum
0210Course Schedule II
0211Design Add and Search Words Data Structure
0213House Robber II
0215Kth Largest Element in an Array
0216Combination Sum III
0221Maximal Square
0223Rectangle Area
0227Basic Calculator II
0229Majority Element II
0230Kth Smallest Element in a BST
0235Lowest Common Ancestor of a Binary Search Tree
0236Lowest Common Ancestor of a Binary Tree
0237Delete Node in a Linked List
0238Product of Array Except Self
0240Search a 2D Matrix II
0241Different Ways to Add Parentheses
0260Single Number III
0264Ugly Number II
0274H-Index
0275H-Index II
0279Perfect Squares
0284Peeking Iterator
0287Find the Duplicate Number
0289Game of Life
0299Bulls and Cows
0300Longest Increasing Subsequence
0304Range Sum Query 2D - Immutable
0306Additive Number
0307Range Sum Query - Mutable
0309Best Time to Buy and Sell Stock with Cooldown
0310Minimum Height Trees
0313Super Ugly Number
0316Remove Duplicate Letters
0318Maximum Product of Word Lengths
0319Bulb Switcher
0322Coin Change
0324Wiggle Sort II
0328Odd Even Linked List
0331Verify Preorder Serialization of a Binary Tree
0334Increasing Triplet Subsequence
0337House Robber III
0341Flatten Nested List Iterator
0343Integer Break
0347Top K Frequent Elements
0355Design Twitter
0357Count Numbers with Unique Digits
0365Water and Jug Problem
0368Largest Divisible Subset
0371Sum of Two Integers
0372Super Pow
0373Find K Pairs with Smallest Sums
0375Guess Number Higher or Lower II
0376Wiggle Subsequence
0377Combination Sum IV
0378Kth Smallest Element in a Sorted Matrix
0380Insert Delete GetRandom O(1)
0382Linked List Random Node
0384Shuffle an Array
0385Mini Parser
0386Lexicographical Numbers
0388Longest Absolute File Path
0390Elimination Game
0393UTF-8 Validation
0394Decode String
0395Longest Substring with At Least K Repeating Characters
0396Rotate Function
0397Integer Replacement
0398Random Pick Index
0399Evaluate Division
0400Nth Digit
0402Remove K Digits
0406Queue Reconstruction by Height
0413Arithmetic Slices
0416Partition Equal Subset Sum
0417Pacific Atlantic Water Flow
0419Battleships in a Board
0421Maximum XOR of Two Numbers in an Array
0423Reconstruct Original Digits from English
0424Longest Repeating Character Replacement
0427Construct Quad Tree
0429N-ary Tree Level Order Traversal
0430Flatten a Multilevel Doubly Linked List