C++17 • Algorithms • Competitive Programming • Problem Solving
- Overview
- Repository Philosophy
- Features
- Study Methodology
- Techniques Covered
- Repository Statistics
- Repository Structure
- Running a Solution
- Problem Summaries
- Progress
- References
- License
This repository contains my solutions to the CSES Introductory Problems implemented in modern C++17.
Rather than serving as a simple collection of accepted solutions, the repository is designed as a structured study of algorithmic problem solving. Every solution emphasizes the underlying algorithmic idea, mathematical reasoning, implementation strategy, and complexity analysis.
The objective is to develop a deeper understanding of classical algorithms, combinatorial reasoning, mathematical observations, and problem-solving techniques commonly encountered in competitive programming, technical interviews, and algorithmic research.
The purpose of this repository is not only to provide accepted solutions to the CSES Problem Set, but also to document the reasoning process behind each algorithm.
Rather than focusing solely on implementation, every problem is approached as a learning opportunity, emphasizing the algorithmic intuition, mathematical foundations, and complexity analysis that lead to an optimal solution.
Each solution follows a consistent methodology:
- Understanding the problem
- Identifying the core idea
- Designing the algorithm
- Explaining the mathematical insight
- Analyzing time and memory complexity
- Producing a clean and efficient implementation
- Clean and optimized C++17 implementations
- Algorithmic explanation for every problem
- Core Idea for each solution
- Algorithm Template
- Mathematical / Algorithmic Insight
- Time and Memory Complexity analysis
- Competitive programming best practices
- Incrementally expanding collection of solutions
- Individual Markdown summaries for every solved problem
Each problem is analyzed using the same structured methodology.
Understand the statement and identify the exact computational task.
Identify the key observation that leads to an optimal solution.
Design the algorithm before implementation.
Explain the mathematical reasoning whenever applicable.
Analyze both time and memory complexity.
Produce a clean, readable and efficient C++ implementation.
As the repository grows, it covers a wide range of classical algorithmic techniques, including
- Simulation
- Greedy Algorithms
- Constructive Algorithms
- Mathematics
- Combinatorics
- Number Theory
- Pattern Recognition
- Backtracking
- Breadth-First Search (BFS)
- Divide and Conquer
- Frequency Counting
- Modular Arithmetic
Documentation
- One summary for every solved problem
Language Standard
- ISO C++17
Every solution includes
- Core Idea
- Algorithm Template
- Key Idea
- Mathematical / Algorithmic Insight
- Time Complexity
- Memory Complexity
cses-introductory-problems-cpp/
│
├── summaries/
│ ├── apple_division.md
│ ├── bit_strings.md
│ ├── ...
│ └── weird_algorithm.md
│
├── src/
│ ├── apple_division.cpp
│ ├── bit_strings.cpp
│ ├── ...
│ └── weird_algorithm.cpp
│
├── README.md
├── LICENSE
└── .gitignore
- C++17 compatible compiler
g++ -std=c++17 -O2 bit_strings.cpp./a.outThe same procedure applies to every solution contained in the repository.
Every solved problem is accompanied by a dedicated Markdown summary that explains the underlying algorithm, mathematical intuition, and complexity analysis.
Each summary includes:
- Problem
- Problem Type
- Core Idea
- Algorithm Template
- Key Idea
- Common Mistakes
- Time Complexity
- Memory Complexity
- Reference Implementation
Use the table below to open the summary for any solved problem.
| Problem | Technique | Summary |
|---|---|---|
| Weird Algorithm | Simulation | View |
| Missing Number | Mathematics | View |
| Repetitions | Linear Traversal | View |
| Increasing Array | Greedy | View |
| Permutations | Constructive Algorithm | View |
| Number Spiral | Mathematics | View |
| Two Knights | Combinatorics | View |
| Two Sets | Constructive Algorithm | View |
| Bit Strings | Combinatorics | View |
| Trailing Zeros | Number Theory | View |
| Coin Piles | Mathematical Observation | View |
| Palindrome Reorder | Frequency Counting | View |
| Gray Code | Constructive Algorithm | View |
| Tower of Hanoi | Recursion | View |
| Creating Strings | Backtracking | View |
| Apple Division | Backtracking | View |
| Chessboard and Queens | Backtracking | View |
| Digit Queries | Mathematical Observation | View |
| String Reorder | Greedy | View |
| Grid Coloring I | Greedy | View |
| Mex Grid Construction | Constructive Algorithm | View |
| Knight Moves Grid | Breadth-First Search (BFS) | View |
| Raab Game I | Constructive Algorithm | View |
| Grid Paths Description | Backtracking | View |
- Weird Algorithm
- Missing Number
- Repetitions
- Increasing Array
- Permutations
- Number Spiral
- Two Knights
- Two Sets
- Bit Strings
- Trailing Zeros
- Coin Piles
- Palindrome Reorder
- Gray Code
- Tower of Hanoi
- Creating Strings
- Apple Division
- Chessboard and Queens
- Raab Game I
- Mex Grid Construction
- Knight Moves Grid
- Grid Coloring I
- Digit Queries
- String Reorder
- Grid Paths Description
The repository is continuously updated as additional problems from the CSES Problem Set are solved and analyzed.
- CSES Problem Set — https://cses.fi/problemset/
- Steven Halim et al., Competitive Programming
- Thomas H. Cormen et al., Introduction to Algorithms (CLRS)
- Donald E. Knuth, The Art of Computer Programming
This project is licensed under the MIT License.
Maintained by Anastasis Zachariou