A comprehensive collection of solutions to the CSES Problem Set - Your Competitive Programming Goldmine! ๐
The CSES Problem Set is a collection of algorithmic programming problems designed to help you learn and practice competitive programming. It covers all fundamental topics from basic algorithms to advanced data structures and techniques.
This repository contains complete solutions to all problems in the CSES Problem Set, organized by topic and difficulty level. Each solution is implemented in C++ with clear explanations and optimal approaches.
- Total Problems: 300+
- Topics Covered: 8 major categories
- Difficulty Levels: Introductory to Advanced
- Language: C++ (with some Python solutions)
- Status: ๐ข Complete Solutions Available
1. ๐ Introductory Problems (19 problems)
- Weird Algorithm - Basic implementation
- Missing Number - Array manipulation
- Repetitions - String processing
- Increasing Array - Greedy algorithms
- Permutations - Combinatorics
- Number Spiral - Pattern recognition
- Two Knights - Combinatorics
- Two Sets - Greedy algorithms
- Bit Strings - Combinatorics
- Trailing Zeros - Mathematics
- Coin Piles - Game theory
- Palindrome Reorder - String manipulation
- Gray Code - Bit manipulation
- Tower of Hanoi - Recursion
- Creating Strings - Permutations
- Apple Division - Subset sum
- Chessboard and Queens - Backtracking
- Digit Queries - Mathematics
- Grid Paths - Dynamic programming
2. ๐ข Sorting and Searching (35 problems)
- Distinct Numbers - Sorting
- Apartments - Two pointers
- Ferris Wheel - Greedy + sorting
- Concert Tickets - Binary search
- Restaurant Customers - Sweep line
- Movie Festival - Greedy algorithms
- Sum of Two Values - Two pointers
- Maximum Subarray Sum - Kadane's algorithm
- Stick Lengths - Median optimization
- Missing Coin Sum - Greedy algorithms
- Collecting Numbers - Permutation cycles
- Collecting Numbers II - Advanced permutation cycles
- Playlist - Two pointers
- Towers - Greedy algorithms
- Traffic Lights - Ordered sets
- Josephus Problem I - Mathematical
- Josephus Problem II - Advanced mathematical
- Nested Ranges Check - Sweep line
- Nested Ranges Count - Sweep line
- Room Allocation - Greedy algorithms
- Factory Machines - Binary search
- Tasks and Deadlines - Greedy algorithms
- Reading Books - Greedy algorithms
- Stick Divisions - Huffman coding
- Cookie Piles - Binary search
- Nested Ranges Check 2 - Advanced sweep line
- Movie Festival Queries - Binary search + offline
- Static Range Sum Queries - Prefix sums
- Static Range Minimum Queries - Sparse table
- Dynamic Range Sum Queries - Segment tree
- Dynamic Range Minimum Queries - Segment tree
- Range Xor Queries - Prefix sums
- Range Update Queries - Difference array
- Forest Queries - 2D prefix sums
- Hotel Queries - Binary search + ordered set
- List Removals - Fenwick tree
- Salary Queries - Coordinate compression + Fenwick tree
3. ๐ Dynamic Programming (19 problems)
- Dice Combinations - Basic DP
- Minimizing Coins - Coin change
- Coin Combinations I - Unbounded knapsack
- Coin Combinations II - Bounded knapsack
- Removing Digits - Digit DP
- Grid Paths - 2D DP
- Book Shop - Knapsack
- Money Sums - Subset sum
- Removal Game - Game theory + DP
- Two Sets II - Subset sum
- Beautiful Permutation - Permutation DP
- Go Go Turtle - Advanced DP
- Decreasing String - String DP
- School Excursion - Knapsack with groups
- Counting Numbers - Digit DP
- Counting Numbers II - Advanced digit DP
- Counting Numbers III - Very advanced digit DP
- Counting Numbers IV - Extremely advanced digit DP
- Counting Numbers V - Ultimate digit DP
4. ๐ณ Graph Algorithms (36 problems)
- Counting Rooms - Flood fill
- Labyrinth - BFS pathfinding
- Building Roads - Minimum spanning tree
- Message Route - BFS shortest path
- Building Teams - Bipartite graph
- Round Trip - Cycle detection
- Monsters - Multi-source BFS
- Shortest Routes I - Dijkstra's algorithm
- Shortest Routes II - Floyd-Warshall
- High Score - Bellman-Ford
- Flight Discount - Modified Dijkstra
- Cycle Finding - Negative cycle detection
- Flight Routes - K-th shortest path
- Round Trip II - Cycle detection in directed graph
- Course Schedule - Topological sorting
- Longest Flight Route - DAG longest path
- Game Routes - DAG counting paths
- Investigation - Modified Dijkstra
- Planets Queries I - Binary lifting
- Planets Queries II - LCA
- Planets Cycles - Cycle detection
- Road Reparation - Minimum spanning tree
- Road Construction - Minimum spanning tree
- Flight Routes Check - Strongly connected components
- Planets and Kingdoms - Strongly connected components
- Giant Pizza - 2-SAT
- Coin Collector - Strongly connected components
- Mail Delivery - Euler tour
- De Bruijn Sequence - Euler tour
- Teleporters Path - Euler tour
- Hamiltonian Flights - Hamiltonian path
- Knight's Tour - Hamiltonian cycle
- Download Speed - Maximum flow
- Police Chase - Minimum cut
- School Dance - Maximum bipartite matching
- Distinct Routes - Maximum flow with capacities
- Distinct Routes II - Advanced maximum flow
5. ๐งฎ Range Queries (19 problems)
- Static Range Sum Queries - Prefix sums
- Static Range Minimum Queries - Sparse table
- Dynamic Range Sum Queries - Segment tree
- Dynamic Range Minimum Queries - Segment tree
- Range Xor Queries - Prefix sums
- Range Update Queries - Difference array
- Forest Queries - 2D prefix sums
- Hotel Queries - Binary search + ordered set
- List Removals - Fenwick tree
- Salary Queries - Coordinate compression + Fenwick tree
- Prefix Sum Queries - Segment tree
- Pizzeria Queries - Segment tree
- Subarray Sum Queries - Segment tree
- Array Distances - Segment tree
- Increasing Array Queries - Segment tree
- Forest Queries II - 2D Fenwick tree
- Range Updates and Sums - Lazy propagation
- Polynomial Queries - Advanced lazy propagation
- Range Queries and Copies - Persistent segment tree
6. ๐ฒ Tree Algorithms (19 problems)
- Subordinates - Tree traversal
- Tree Matching - Tree DP
- Tree Diameter - Two DFS
- Tree Distances I - Tree DP
- Tree Distances II - Rerooting
- Company Queries I - Binary lifting
- Company Queries II - LCA
- Distance Queries - LCA
- Counting Paths - Tree DP + LCA
- Subtree Queries - Euler tour + segment tree
- Path Queries - Heavy-light decomposition
- Path Queries II - Heavy-light decomposition
- Distinct Colors - Small to large merging
- Finding a Centroid - Centroid decomposition
- Fixed-Length Paths I - Centroid decomposition
- Fixed-Length Paths II - Advanced centroid decomposition
- Fixed-Length Paths III - Very advanced centroid decomposition
- Fixed-Length Paths IV - Extremely advanced centroid decomposition
- Fixed-Length Paths V - Ultimate centroid decomposition
7. ๐ Mathematics (31 problems)
- Josephus Queries - Mathematical
- Exponentiation - Fast exponentiation
- Exponentiation II - Fermat's little theorem
- Counting Divisors - Sieve of Eratosthenes
- Common Divisors - GCD properties
- Sum of Divisors - Multiplicative functions
- Divisor Analysis - Prime factorization
- Prime Multiples - Inclusion-exclusion
- Counting Coprime Pairs - Mรถbius function
- Binomial Coefficients - Lucas theorem
- Creating Strings II - Combinatorics
- Distributing Apples - Stars and bars
- Christmas Party - Derangements
- Bracket Sequences I - Catalan numbers
- Bracket Sequences II - Advanced Catalan numbers
- Counting Necklaces - Burnside's lemma
- Counting Grids - Burnside's lemma
- Fibonacci Numbers - Matrix exponentiation
- Thue-Morse Sequence - Recursive sequences
- Acyclic Graph Edges - Combinatorics
- Strongly Connected Edges - Graph theory
- Even Outdegree Edges - Graph theory
- Critical Cities - Articulation points
- School Excursion - Knapsack with groups
- Coin Grid - Maximum bipartite matching
- Robot Path - Combinatorics
- Programmers and Artists - Combinatorics
- Course Schedule II - Topological sorting
- Removing Digits II - Advanced digit DP
- Counting Reorders - Combinatorics
- Book Shop II - Advanced knapsack
- Network Breakdown - Minimum spanning tree
- Visiting Cities - Traveling salesman problem
8. ๐ฎ Advanced Techniques (19 problems)
- Substring Reversals - String algorithms
- Reversals and Sums - Advanced string algorithms
- Necessary Roads - Bridge finding
- Necessary Cities - Articulation points
- Eulerian Subgraphs - Graph theory
- Monster Attack I - Advanced algorithms
- Monster Attack II - Very advanced algorithms
- Monster Attack III - Extremely advanced algorithms
- Monster Attack IV - Ultimate algorithms
- Monster Attack V - Legendary algorithms
- String Reorder - Advanced string algorithms
- Stack Weights - Advanced data structures
- Pyramid Array - Advanced algorithms
- Increasing Subsequence - Advanced DP
- String Removals - Advanced string algorithms
- Bit Inversions - Advanced bit manipulation
- Xor Pyramid - Advanced bit manipulation
- Writing Numbers - Advanced algorithms
- String Transform - Advanced string algorithms
- C++ compiler (GCC 9.0+ or Clang 10.0+)
- Basic knowledge of algorithms and data structures
- Competitive programming experience (beginner to intermediate)
- Browse by Category: Navigate to the topic you want to learn
- Study Solutions: Each problem has a complete C++ solution with comments
- Practice: Try solving problems yourself before looking at solutions
- Learn: Understand the algorithms and techniques used
Dynamic_Programming/
โโโ Dice_Combinations.cpp # Basic DP solution
โโโ Minimizing_Coins.cpp # Coin change problem
โโโ Coin_Combinations_I.cpp # Unbounded knapsack
โโโ README.md # Category overview
- CSES Problem Set - Main problem collection
- CP Handbook - Free competitive programming textbook
- AskSenior.edu - Advanced problem solving techniques
- Codeforces - Weekly contests and problems
- CodeChef - Monthly contests and practice
- AtCoder - Japanese competitive programming platform
- LeetCode - Interview preparation problems
- Striver's CP Sheet - Comprehensive DSA course
- USACO Guide - American competitive programming guide
- CP Algorithms - Algorithm implementations and explanations
- William Fiset - Graph algorithms and data structures
- Errichto - Competitive programming tutorials
- SecondThread - Problem solving approaches
- CSES Problems Solved: 300+ (Complete Set)
- Codeforces Rating: [Your Rating] - [Your Handle]
- CodeChef Rating: [Your Rating] - [Your Handle]
- Total Problems Solved: 500+ across platforms
- [List your achievements, contest rankings, etc.]
- [Mention any specializations or strong areas]
This repository is a personal collection of solutions. However, if you find any bugs or have suggestions for improvements, feel free to:
- Open an issue
- Submit a pull request
- Contact me directly
This project is for educational purposes. All problems belong to their respective owners (CSES, Codeforces, etc.).
- CSES Team for creating this amazing problem set
- Competitive Programming Community for continuous learning
- Open Source Contributors who share their knowledge
- GitHub: [Your GitHub Profile]
- LinkedIn: [Your LinkedIn Profile]
- Email: [Your Email]
โญ Star this repository if you find it helpful! โญ
"The only way to learn a new programming language is by writing programs in it." - Dennis Ritchie