Level 0 Training

Your foundation in C++ and competitive programming. From your first program to efficient range queries, build understanding one small step at a time.

01
Session 1

Programming foundations

Turn a problem statement into a working C++23 program. Learn input, data types, safe arithmetic, decisions, loops, and the habits that make a solution correct.

01

From a problem to a program

Identify the input, output, and constraints, then translate a small plan into C++.

02

Variables, types, and remembered values

Choose a representation, initialize it, and understand what assignment really changes.

03

Arithmetic without surprises

Predict division and remainder, widen before multiplication, and format decimal answers.

04

Conditions and logical decisions

Build exclusive categories, combine comparisons, and protect operations with short-circuit logic.

05

Optional: other ways to choose

Recognize switch for exact choices and the conditional operator for choosing a value.

06

For loops: make repetition precise

Trace initialization, condition, body, and update—and avoid an extra iteration.

07

While, do-while, and stopping rules

Choose a loop from its stopping condition and read the exact input format.

08

Break, continue, and early answers

Distinguish leaving a loop from skipping one iteration, without losing required input.

09

Five patterns worth understanding

Use sums, counts, best-so-far candidates, products, and flags to process a stream.

10

Nested loops: rows and columns

Translate a shape into two loop roles and count the total work.

11

Take a number apart, one digit at a time

Use remainder and division to process decimal digits, including zero.

12

Multiple cases and a debugging mindset

Combine the patterns, isolate each case, and test the boundaries that can break your idea.

02
Session 2

Arrays & strings

Store and revisit values, work with rows and columns, and treat text as a sequence of characters. Build safe scans, searches, transformations, and small state machines.

01

Arrays: give every value a place

Understand indices, initialization, capacity, active length, and the first safe array loop.

02

Scan, count, search, and compare

Distinguish values from positions and preserve the exact tie rule a problem asks for.

03

Change a sequence without losing it

Update, copy, compare, reverse, and inspect neighbours using the correct bounds.

04

Matrices: think in two coordinates

Traverse tables, total rows and columns, inspect diagonals, and protect grid neighbours.

05

Characters become strings

Separate characters from numbers, then safely inspect and edit managed text.

06

Read the text the problem actually gives

Choose words or full lines, preserve empty cases, and reset only the state that needs it.

07

Scan text: count, filter, transform

Build a result from matching characters without losing leading zeros or skipping shifted text.

08

Join, compare, and find text

Learn content comparison, lexicographical order, substring counts, and the not-found sentinel.

09

Mirror pairs and common beginnings

Check palindromes and shared prefixes without changing the text or crossing its boundaries.

10

Word boundaries and reliable text tests

Remember whether you are inside a word, then use small boundary cases to audit a scan.

11

Optional: rearrange an active sequence

Use half-open algorithm ranges and preserve values while shifting, rotating, inserting, or deleting.

12

Optional: subsequences and useful tools

Distinguish consecutive pieces from ordered selections, then recognize safer library conveniences.

03
Session 3

Functions & complexity

Build reusable C++ helpers, make their contracts explicit, and count time and memory before the input gets large.

01

One function, one clear job

Follow a call from its arguments to its return value, and distinguish declarations from definitions.

02

Return, print, and start fresh

Use return values, void actions, early exits, and local scope deliberately.

03

Copies, references, and side effects

Predict whether a function can change its caller by reading its parameter types.

04

Array helpers need a contract

Pass an active length, protect read-only inputs, and define missing results and tie rules.

05

Strings and small helper teams

Read strings without copying, return transformed values safely, and compose helpers with clear tests.

06

Describe growth with Big-O

Name the input sizes and separate operation counts, growth bounds, and actual runtime.

07

Look past the number of loops

Count rectangular, triangular, shared-counter, and growing-chunk loops correctly.

08

Halving and square-root work

Recognize logarithmic progress and build a prime test with a safe inclusive boundary.

09

The work hidden in a call

Include copied parameters, helper bodies, string operations, and input/output in your estimate.

10

Memory, limits, and many test cases

Count peak live storage and total work across cases before choosing an algorithm.

11

Optional: more expressive interfaces

Explore overloads, default arguments, and fixed-width matrix parameters after mastering ordinary calls.

12

Optional: recursion and pending work

Trace a base case, the return journey, total calls, and peak call depth.

04
Session 4

STL: sequences & adaptors

Learn vector, pair, deque, queue, priority_queue, and stack through state changes, ordering rules, and the cost of each operation.

01

Meet your standard-library toolkit

Choose an interface by the next operation you need, and construct vectors with the intended contents.

02

Vector elements, size, and room

Traverse safely and distinguish existing elements from reserved storage.

03

Iterators, edits, and invalidation

Use half-open ranges and reason about positions after structural changes.

04

Algorithms over a range

Sort, reverse, search, sum, remove, and deduplicate with the right return types and costs.

05

Vectors in functions and grids

Choose copies or references deliberately and traverse nested vectors without assuming every row matches.

06

Pairs and precise tie rules

Keep related values together and make ordering requirements explicit.

07

Deque: work at either end

Keep recent arrivals and make front/back updates without repeated vector shifts.

08

Queue: serve the oldest first

Model FIFO commands, repeated turns, copies, and fresh state between test cases.

09

Priority queues: choose the next extreme

Use max-heaps, min-heaps, and pair priorities without confusing heap order with full sorting.

10

Stack: resolve the newest first

Learn LIFO and use it to check all three kinds of bracket nesting.

11

Cancellation, undo, and combined tools

Use a reduced-prefix invariant, preserve action history, and combine a queue with a stack.

12

Optional: keep only the best k

Use a small min-heap to retain the largest arrivals, and justify the invariant and costs.

05
Session 5

Sets & maps

Choose between distinct keys, repeated items, key–value records, and dynamic ranks. Trace the state, make safe updates, and count the real cost.

01

Think in keys, not positions

Choose a representation, build a set, and ask whether a key exists.

02

Walk and erase safely

Understand iterators, extremes, references, and deletion loops.

03

Find the nearest valid key

Translate thresholds into lower bounds, upper bounds, and predecessors.

04

Every copy counts

Use multisets to represent stock and sell exactly one affordable item.

05

One key, one record

Use maps without confusing lookup, insertion, and replacement.

06

Counts, ties, and groups

Build frequency maps, resolve ties, and preserve occurrence positions.

07

Hashing and exact-key queries

Understand unordered maps, deterministic output, and average versus worst-case cost.

08

Ask the past before adding the present

Solve two-sum safely and choose a container by required operations.

09

Ranks with a GNU ordered set

Count smaller keys and select a zero-based rank efficiently.

10

Ranks change; identities do not

Update ranked sets and optionally preserve duplicate occurrences with IDs.

11

Optional: combine and compare keys

Use composite keys, set intersections, and explicit ordering rules.

12

Make the state tell the truth

Maintain active frequencies, reset test cases, and debug the representation first.

06
Session 6

Static range queries

Build prefix totals, count bounded values, and record range additions at their boundaries. Extend the same reasoning to substrings, grids, and layered queries.

01

Build once. Query many times.

Derive prefix sums from their meaning and cancel the unwanted beginning.

02

Safe sums and honest complexity

Choose wide types, avoid query-time copies, and recognize stale summaries.

03

Transform the question into a sum

Count conditions, evaluate fixed windows, and compare both sides of a pivot.

04

Count values with direct indexing

Size the domain, handle signed keys with offsets, and find a mode.

05

Letters and equal pairs

Preserve multiplicity in a small alphabet and count pairs as they arrive.

06

Which axis are you prefixing?

Count values in a numeric interval or letters inside a substring.

07

Add to a range with two markers

Record boundary changes and reconstruct all values after the updates.

08

Build a pipeline of summaries

Combine initial values, offline additions, coverage conditions, and final queries.

09

Prefix sums in two dimensions

Use inclusion-exclusion for rectangles and marked-cell counts.

10

Optional: different kinds of totals

Use numeric helpers correctly and derive weighted or modular prefix formulas.

11

Optional: sparse values and rectangle updates

Compress an enormous value domain or extend difference markers to a grid.

12

Optional challenge: find matching prefixes

Count target-sum subarrays and verify every summary against its meaning.

From a problem to a programIdentify the input, output, and constraints, then translate a small plan into C++.Variables, types, and remembered valuesChoose a representation, initialize it, and understand what assignment really changes.Arithmetic without surprisesPredict division and remainder, widen before multiplication, and format decimal answers.Conditions and logical decisionsBuild exclusive categories, combine comparisons, and protect operations with short-circuit logic.Optional: other ways to chooseRecognize switch for exact choices and the conditional operator for choosing a value.For loops: make repetition preciseTrace initialization, condition, body, and update—and avoid an extra iteration.While, do-while, and stopping rulesChoose a loop from its stopping condition and read the exact input format.Break, continue, and early answersDistinguish leaving a loop from skipping one iteration, without losing required input.Five patterns worth understandingUse sums, counts, best-so-far candidates, products, and flags to process a stream.Nested loops: rows and columnsTranslate a shape into two loop roles and count the total work.Take a number apart, one digit at a timeUse remainder and division to process decimal digits, including zero.Multiple cases and a debugging mindsetCombine the patterns, isolate each case, and test the boundaries that can break your idea.Arrays: give every value a placeUnderstand indices, initialization, capacity, active length, and the first safe array loop.Scan, count, search, and compareDistinguish values from positions and preserve the exact tie rule a problem asks for.Change a sequence without losing itUpdate, copy, compare, reverse, and inspect neighbours using the correct bounds.Matrices: think in two coordinatesTraverse tables, total rows and columns, inspect diagonals, and protect grid neighbours.Characters become stringsSeparate characters from numbers, then safely inspect and edit managed text.Read the text the problem actually givesChoose words or full lines, preserve empty cases, and reset only the state that needs it.Scan text: count, filter, transformBuild a result from matching characters without losing leading zeros or skipping shifted text.Join, compare, and find textLearn content comparison, lexicographical order, substring counts, and the not-found sentinel.