Practice problems
Choose a coding problem by topic, or trace a worked solution.
Arrays & Pointers
17 problems
- EasyKattis
Given an operation budget, an input size, and one of seven growth functions, decide whether the algorithm fits the budget. The problem treats each stated function as an exact operation count.
Core practice Compare linear, polynomial, exponential, and factorial growth at concrete input sizes. Avoid overflow when the answer already exceeds the budget; this practises time growth, not RAM layout.
- EasyLeetCode
Choose one buy day and a later sell day to maximize profit, or return zero if no profitable transaction exists.
Core practice A focused single-pass state invariant: distinguish the best earlier purchase from the current candidate sale.
- EasyAizu Online Judge
Process up to 200,000 append, indexed-read, and remove-last operations on an initially empty dynamic array. Print the value requested by each indexed read.
Core practice Exercise the defining dynamic-array operations through a judged command stream. Track length across append and pop; explain amortized append cost separately because capacity is not part of the judged output.
- EasyLeetCode
Reverse an array of characters in place using constant extra memory.
Core practice Work directly with mutable characters and test even and odd lengths without allocating a reversed copy.
- MediumLeetCode
Return all elements of a rectangular matrix in clockwise spiral order.
Core practice Track shrinking row and column bounds without visiting the last row or column twice.
- EasyLeetCode
Ignore non-alphanumeric characters and letter case, then decide whether the remaining sequence reads the same in both directions.
Tags Two pointers
Core practice Practice inward scans with independent skipping rules and careful crossing conditions.
- MediumLeetCode
Choose two vertical lines that form a container holding the greatest possible area of water.
Tags Two pointers
Core practice Prove which endpoint can safely move; this introduces elimination reasoning beyond a symmetric scan.
Try firstValid Palindrome - EasyLeetCode
Return the squares of a sorted integer array in nondecreasing order; the follow-up asks for linear time.
Extra challenge Extra: handle negative values by merging candidates from both ends without sorting again.
Try firstValid Palindrome