Back home

The C++ practice arena

Solve it. Run it.

Write or upload C++17, edit your own visible cases, then submit against hidden tests. Passing solutions get real runtime, memory, and a playful percentile.

22 judged problemsEditor or .cppTime + memory

One attempt, three steps

  1. 01Write

    Use the editor or upload a .cpp file.

  2. 02Run

    Compare visible input and output.

  3. 03Submit

    Face hidden cases and record the result.

Drafts stay local. Verified progress syncs to your account.

Your next run

Rotate in place

Rotate a vector right by k positions without allocating another vector.

Start first challengeLinear · Foundation

Arena progress

0/22

0% completeLoading progress
Find a challenge

Filter by topic or search for a technique.

Challenge queue

Pick one and open the editor.

22 shown

04Linear C++17
Foundation

Rotate in place

Rotate a vector right by k positions without allocating another vector.

Technique: three reversals
Target: O(n) time, O(1) extra
05Linear C++17
Foundation

Best contiguous sum

Find the maximum sum of a non-empty contiguous subarray, including when every value is negative.

Technique: Kadane's algorithm
Target: O(n) time, O(1) extra
06Linear C++17
Intermediate

Longest unique window

Find the length of the longest substring with no repeated character.

Technique: sliding window + frequency
Target: O(n) expected
07Linear C++17
Foundation

Anagram check

Decide whether two lowercase strings contain exactly the same characters with the same frequencies.

Technique: fixed frequency array
Target: O(n) time, O(1) alphabet space
11Linear C++17
Foundation

Balanced brackets

Validate (), [], and {} while reporting the first bad index.

Technique: stack of opening tokens
Target: O(n)
12Linear C++17
Intermediate

Next greater value

For every array element, find the first greater element to its right.

Technique: monotonic stack
Target: O(n)
14Linear C++17
Foundation

Serve the queue

Process PUSH, POP, and FRONT commands while handling an empty queue safely.

Technique: FIFO state simulation
Target: O(1) per command
15Linear C++17
Foundation

Frequency table

Return the first array value whose frequency reaches two.

Technique: unordered_set
Target: O(n) expected
17Searching C++17
Foundation

First matching index

Find the first occurrence of a target in an unsorted array, or report that it is absent.

Technique: left-to-right scan
Target: O(n)
18Searching C++17
Foundation

First occurrence

Return the first index of target in a sorted array containing duplicates.

Technique: lower bound
Target: O(log n)
19Searching C++17
Intermediate

Minimum feasible speed

Given workloads and h hours, find the smallest integer speed that finishes all work.

Technique: binary search on answer
Target: O(n log range)
20Searching C++17
Challenge

Search rotated data

Locate a key in a strictly increasing array rotated at an unknown pivot.

Technique: identify sorted half
Target: O(log n)
23Sorting C++17
Foundation

Count insertion moves

Run insertion sort conceptually and count how many right-shifts are required to sort the array.

Technique: insertion-sort trace
Target: O(n²) worst case
24Sorting C++17
Intermediate

Count inversions

Count pairs i<j with a[i]>a[j] without checking all pairs.

Technique: merge-sort augmentation
Target: O(n log n)
25Sorting C++17
Challenge

Kth smallest

Find the kth smallest element without fully sorting the input.

Technique: quickselect partition
Target: O(n) average
30Trees C++17
Intermediate

Validate the whole BST

Validate a serialized binary tree using ancestor bounds rather than checking only each parent.

Technique: recursive range propagation
Target: O(n)
31Heaps C++17
Foundation

Is it a min heap?

Check whether an array representation satisfies the min-heap order property at every parent.

Technique: parent-child index checks
Target: O(n)
32Heaps C++17
Intermediate

Running kth largest

Report the kth largest value after every item in a stream.

Technique: size-k min heap
Target: O(n log k)
34Graphs C++17
Foundation

Count components

Count connected components in an undirected graph and label every vertex.

Technique: repeated BFS/DFS
Target: O(V+E)
36Graphs C++17
Intermediate

Dependency cycle

Detect a cycle in a directed dependency graph.

Technique: three-colour DFS
Target: O(V+E)
38Graphs C++17
Intermediate

Shortest weighted routes

Compute the shortest distance from one source to every vertex in a non-negative weighted graph.

Technique: Dijkstra + stale-entry rejection
Target: O((V+E) log V)
39Graphs C++17
Intermediate

Dynamic connectivity

Process union and connected queries using path compression and union by size.

Technique: DSU
Target: near-constant amortized