Skip to content
difficulty

Intermediate

Articles whose authoritative difficulty is intermediate.

Tagged articles

Intermediate articles

62 articles in this tag.

Professional team discussing analytics and brainstorming ideas in a meeting room.
intermediate
12 min read

3Sum Closest

The target does not identify the winning triplet. It tells each pointer which direction is still worth exploring.

View solution
Close-up of hands coding on a laptop, showcasing software development in action.
intermediate
10 min read

3Sum

A reliable 3Sum solution comes from turning a cubic search into a sequence of sorted two-sum scans—and proving why each pointer move is safe.

View solution
A person working on a laptop with a red notebook and glasses on a white table.
intermediate
10 min read

Add Two Numbers

The lists already expose digits in the order addition needs. Scan both lists together, track one carry, and keep going until there is no digit or carry…

View solution
Overhead view of a MacBook laptop on a dark desk, showcasing modern technology and minimalism.
intermediate
12 min read

Combination Sum II

The hard part is not finding combinations that add to the target. It is finding them once while respecting the physical number of occurrences in the input.

View solution
Dark-themed laptop setup with a red glowing keyboard and code on screen, ideal for tech enthusiasts.
intermediate
10 min read

Combination Sum

Treat this as an enumeration problem, not a permutation problem. Sort the candidates, keep combinations in nondecreasing order, recurse from the same index…

View solution
3D rendered abstract brain concept with neural network.
intermediate
11 min read

Combinations

The duplicate-ordering trap is the whole problem: [1, 2] and [2, 1] represent one selection, not two. Build every path in increasing order, and the…

View solution
Laptop on green grass in sunlight. Ideal for remote work and technology themes.
intermediate
9 min read

Container With Most Water

The hard part is not calculating width × shorter_height. It is proving why one whole family of pairs can be discarded without checking them.

View solution
A stylish workspace featuring a laptop, plant, and smartphone on a desk.
intermediate
10 min read

Count and Say

The Count and Say solution is a repeated state transition: start with "1", scan the current string into maximal consecutive runs, and emit each run as…

View solution
Open laptop with a colorful display reflecting on its keyboard, set against a dark background.
intermediate
11 min read

Decode Ways

The recurrence resembles Fibonacci, but zeros can remove transitions entirely. Derive the valid-token transitions first; the dynamic program then follows…

View solution
Illustration of a stock market chart with red and green data, showing market trends and analytics.
intermediate
10 min read

Generate Parentheses

Generate only prefixes that can still become valid. The balance state tells you exactly which branches to keep.

View solution
Collection of handmade terracotta pots and plates on display with garden background.
intermediate
11 min read

Gray Code

Gray code looks like a permutation problem, but the useful signal is more specific: enumerate every n-bit state so that each move flips exactly one bit,…

View solution
Person interacts with robot images on a screen in a dark room, highlighting technology use.
intermediate
9 min read

Group Anagrams

A useful Group Anagrams solution does not compare every string with every existing group. It assigns each string a stable identity based on its character…

View solution
Dried flowers scattered beautifully on a white background, showcasing nature's delicate remnants.
intermediate
10 min read

Insert Interval

The common trap in the Insert Interval solution is treating the task as generic sorting followed by generic interval merging. That works, but it ignores…

View solution
High-angle drone shot capturing vibrant green farm field patterns from above.
intermediate
11 min read

Jump Game II

The common mistake in a Jump Game II solution is to commit too early: “From this index, which landing position should I choose?” That creates a path-search…

View solution
A laptop glows in a dark room at night with a cityscape through the window. Ideal for tech and solitude themes.
intermediate
10 min read

Jump Game

The wrong mental model is a tree of jump paths. The useful model is a moving boundary: the farthest index reachable by any valid path found so far.

View solution
Explore the serene and vibrant beauty of a sprawling oak tree in a lush green forest, perfect for nature lovers.
intermediate
10 min read

Maximum Subarray

Resetting a running sum to zero looks like the obvious solution—until the array contains only negative numbers. Then the algorithm can quietly return an…

View solution
Detailed view of network cables plugged into a server rack in a data center.
intermediate
11 min read

Merge Intervals

Pairwise merging feels natural until one merge creates a new overlap with a third interval. Then the bookkeeping branches, earlier comparisons become…

View solution
Detailed view of an Opt Lasers engraving machine in operation, showcasing precision technology.
intermediate
11 min read

Minimum Path Sum

The right Minimum Path Sum solution is a two-dimensional dynamic program. For every coordinate, store the minimum sum needed to reach it from the top-left.…

View solution
Detailed view of tree trunk with visible growth rings, showcasing natural wood texture.
intermediate
10 min read

Multiply Strings

Treat the product as a fixed array of decimal positions. Every digit pair has a predictable destination; carry normalization keeps those positions valid.

View solution
Close-up of a moss-covered tree trunk in a dark, moody forest setting.
intermediate
10 min read

Partition List

A linked-list partition fails in one of two ways: it loses the unread suffix, or it preserves a stale link and creates the wrong structure. The reliable…

View solution
Wide-angle view of a towering sand dune against a vibrant blue sky, showcasing the beauty of desert landscapes.
intermediate
10 min read

Path Sum II

That is the central trap in Path Sum II. An internal node may bring the running sum to targetSum, but its path is still incomplete if the node has a child.…

View solution
A stack of traditional terracotta pots in a Vietnamese pottery workshop, illustrating local craftsmanship.
intermediate
12 min read

Permutations II

When nums = [1, 1, 2], ordinary permutation backtracking treats the two 1 values as different input positions. That creates duplicate value sequences.

View solution
Detailed view of rough and dry brown soil, showcasing its natural texture.
intermediate
11 min read

Permutations

The search tree is easy to recognize and easy to corrupt. Build one position at a time, choose an unused value, recurse, then undo exactly that choice.

View solution
Close-up of a young plant sprout with soil beside empty terracotta pots on a garden table.
intermediate
11 min read

Pow(x, n)

A linear multiplication chain follows the definition of a power. It also ignores the only fact that matters at interview scale: the exponent can be halved.

View solution
Close-up of dual computer monitors with green coding interfaces in a dark room, highlighting cyber security themes.
intermediate
10 min read

Restore IP Addresses

The trap is to think “place three dots.” The useful model is narrower: choose exactly four contiguous digit segments, validate each one immediately, and…

View solution
Asian students in uniform learning in a computer lab, focused on their tasks.
intermediate
11 min read

Reverse Integer

Reversing digits is easy. Reversing them without ever creating an unsafe intermediate value is the interview problem.

View solution
Silhouette of a person walking on a vast sand dune in the desert at sunset in Huacachina, Peru.
intermediate
12 min read

Reverse Linked List II

A localized reversal fails at the boundaries: the middle looks correct, but the prefix disappears, the suffix becomes unreachable, or the returned head is…

View solution
From above of green leaves on thin branches of plant growing in botanical garden
intermediate
10 min read

Rotate Image

The hard part of rotating a matrix is not visualizing the turn. It is moving every value without destroying one that has not moved yet.

View solution
Factory chimneys emitting smoke over rooftops on a clear day, illustrating urban pollution.
intermediate
11 min read

Rotate List

A right rotation looks repetitive when described one node at a time. The useful implementation is one split, one reconnection, and one cut.

View solution
Businesswoman working on laptop with Android 6.0 Marshmallow webpage open.
intermediate
10 min read

Search a 2D Matrix

A matrix can be two-dimensional storage with a one-dimensional search space. Prove that shape first, then run ordinary binary search over virtual indices.

View solution
Close-up of a tablet displaying analytics charts on a wooden office desk, alongside a smartphone and coffee cup.
intermediate
12 min read

Set Matrix Zeroes

The dangerous part is not writing zeroes. It is remembering which zeroes were causes and which zeroes were created by your own writes.

View solution
Group of teenagers using a vending machine in a school corridor, captured in ambient lighting.
intermediate
9 min read

Simplify Path

Treating this as string cleanup is how you lose the problem. Removing every dot breaks valid names such as ..., while careless parent handling can let /../…

View solution
Aerial photograph of a tractor working in a vast, vibrant green field captured from above.
intermediate
11 min read

Sort Colors

The trap in the Sort Colors solution is assuming that “only three values” makes the problem trivial. Counting works. The interview version asks you to see…

View solution
Detailed view of a circular saw blade in an industrial workshop, showcasing precision and craftsmanship.
intermediate
8 min read

Spiral Matrix II

The key distinction is simple: Spiral Matrix reads values from an existing grid; Spiral Matrix II constructs the grid while the spiral advances. The…

View solution
Vibrant close-up of network cable connectors with colorful lighting.
intermediate
10 min read

Spiral Matrix

A spiral traversal can look correct on a square matrix and still fail immediately on a single row or column. The reliable model is a shrinking rectangle:…

View solution
Detailed shot of microchips on a circuit board, showcasing electronic technology and precision engineering.
intermediate
10 min read

String to Integer (atoi)

A reliable atoi parser is a small state machine: skip leading spaces, read one optional sign, consume one numeric prefix, and guard every accumulator…

View solution
A breathtaking view of a desert landscape with a vibrant sunset illuminating the horizon.
intermediate
12 min read

Subsets II

The duplicate bug comes from treating equal input positions as different decisions. Sort first, then skip equal candidates only when they are siblings at…

View solution
A serene beach with soft sand, gentle waves, and lush green trees. Perfect for a nature escape.
intermediate
11 min read

Swap Nodes in Pairs

A value swap can produce the right sequence while violating the contract. The real task is to move node identities by changing links—and to do it without…

View solution
A well-lit home office setup featuring a laptop, monitor, and glasses, ideal for remote work.
intermediate
9 min read

Triangle

The trap is visible: every row offers two choices, so it is tempting to choose the smaller child or enumerate every path. The reliable Triangle solution…

View solution
A cardboard robot figurine standing amid lush green grass outdoors during the day.
intermediate
12 min read

Unique Paths II

The recurrence is familiar. The interview usually turns on the cells you forgot: a blocked start, a blocked destination, or an obstacle that permanently…

View solution
Crop unrecognizable female student doing Internet research on laptop while sitting on cozy blanket in green summer park on sunny day
intermediate
10 min read

Unique Paths

The reliable way to solve Unique Paths is to count paths to each cell, not to enumerate complete routes. Every cell has at most two meaningful…

View solution
A modern open laptop with a black screen placed on lush green grass, symbolizing technology and nature.
intermediate
8 min read

Valid Sudoku

A Sudoku validator does not solve the puzzle. It tracks whether the digits already placed violate any row, column, or 3×3 box constraint.

View solution
A child actively assembling a robotics project with electronic components, showcasing technology education.
intermediate
14 min read

Word Search

A grid DFS can match the right letters and still be wrong. The missing piece is path-local state: mark a cell when you enter it, explore from that choice,…

View solution
A neat workspace featuring a laptop displaying Google search, a smartphone, and a notebook on a wooden desk.
intermediate
11 min read

Zigzag Conversion

A visual zigzag is easy to draw and surprisingly easy to implement incorrectly. The reliable solution is smaller: track the current row, track the movement…

View solution