CSES Problem Set

Introductory Problems

Short constructive, simulation, and arithmetic tasks that make good first passes for the archive. Official CSES statements are linked on every page instead of being mirrored here.

15 published solutions
20 distinct tags
basic, intermediate levels in this category
May 21, 2026 most recently updated page

Published pages in this category

Solved pages include an original summary, rendered editorial, optional pseudocode, complexity analysis, and the exact `solution.cpp` source file.

Introductory Problems #01

Weird Algorithm

basic

Generate the Collatz sequence starting from n and print every value until the sequence reaches 1.

Solved simulationmath
Introductory Problems #02

Missing Number

basic

One value from 1 through n is absent from the input list; recover it without sorting.

Solved mathsum
Introductory Problems #04

Increasing Array

basic

Count the minimum total increment needed to make the array non-decreasing.

Solved greedyarrays
Introductory Problems #05

Permutations

basic

Construct a permutation of 1 through n where neighboring values never differ by exactly 1.

Solved constructivepermutation
Introductory Problems #06

Number Spiral

basic

For each grid coordinate, compute the value stored there in the square spiral without simulating the whole grid.

Solved mathpattern
Introductory Problems #07

Two Knights

basic

For every board size from 1 to n, count how many ways two knights can be placed without attacking each other.

Solved mathcounting
Introductory Problems #08

Two Sets

intermediate

Split 1 through n into two groups with equal sum, or report that such a partition does not exist.

Solved constructivegreedy
Introductory Problems #10

Trailing Zeros

basic

Count how many zeros appear at the end of n! without computing the factorial itself.

Solved factorialsnumber theory
Introductory Problems #11

Coin Piles

basic

Decide whether two piles can both be emptied when each move removes two coins from one pile and one coin from the other.

Solved mathinvariants
Introductory Problems #12

Palindrome Reorder

basic

Rearrange the letters into a palindrome when possible, otherwise report that no such arrangement exists.

Solved stringsgreedycounting
Introductory Problems #13

Gray Code

intermediate

Print all n-bit Gray codes so that consecutive strings differ in exactly one bit.

Solved bitmasksconstructive
Introductory Problems #14

Tower of Hanoi

intermediate

Print the minimum sequence of moves that transfers all disks from the first peg to the third peg.

Solved recursionconstructive
Introductory Problems #15

Creating Strings

intermediate

Enumerate every distinct permutation of the given string in lexicographic order.

Solved stringspermutationsbacktracking