Skip to content

priyanshscpp/CSES-Problem-Set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

68 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ CSES Problem Set Solutions

A comprehensive collection of solutions to the CSES Problem Set - Your Competitive Programming Goldmine! ๐Ÿ†

CSES C++ Competitive Programming

๐Ÿ“š About CSES Problem Set

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.

๐ŸŽฏ Repository Overview

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.

๐Ÿ“Š Statistics

  • Total Problems: 300+
  • Topics Covered: 8 major categories
  • Difficulty Levels: Introductory to Advanced
  • Language: C++ (with some Python solutions)
  • Status: ๐ŸŸข Complete Solutions Available

๐Ÿ—‚๏ธ Problem Categories

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

๐Ÿš€ Getting Started

Prerequisites

  • C++ compiler (GCC 9.0+ or Clang 10.0+)
  • Basic knowledge of algorithms and data structures
  • Competitive programming experience (beginner to intermediate)

How to Use

  1. Browse by Category: Navigate to the topic you want to learn
  2. Study Solutions: Each problem has a complete C++ solution with comments
  3. Practice: Try solving problems yourself before looking at solutions
  4. Learn: Understand the algorithms and techniques used

Example Problem Structure

Dynamic_Programming/
โ”œโ”€โ”€ Dice_Combinations.cpp          # Basic DP solution
โ”œโ”€โ”€ Minimizing_Coins.cpp          # Coin change problem
โ”œโ”€โ”€ Coin_Combinations_I.cpp       # Unbounded knapsack
โ””โ”€โ”€ README.md                     # Category overview

๐Ÿ“š Learning Resources

๐ŸŽฏ Essential Resources

๐Ÿ† Practice Platforms

  • Codeforces - Weekly contests and problems
  • CodeChef - Monthly contests and practice
  • AtCoder - Japanese competitive programming platform
  • LeetCode - Interview preparation problems

๐Ÿ“– Study Materials

๐ŸŽฅ Video Resources

  • William Fiset - Graph algorithms and data structures
  • Errichto - Competitive programming tutorials
  • SecondThread - Problem solving approaches

๐Ÿ… My Competitive Programming Profile

๐Ÿ“Š Statistics

  • CSES Problems Solved: 300+ (Complete Set)
  • Codeforces Rating: [Your Rating] - [Your Handle]
  • CodeChef Rating: [Your Rating] - [Your Handle]
  • Total Problems Solved: 500+ across platforms

๐Ÿ† Achievements

  • [List your achievements, contest rankings, etc.]
  • [Mention any specializations or strong areas]

๐Ÿค Contributing

This repository is a personal collection of solutions. However, if you find any bugs or have suggestions for improvements, feel free to:

  1. Open an issue
  2. Submit a pull request
  3. Contact me directly

๐Ÿ“ License

This project is for educational purposes. All problems belong to their respective owners (CSES, Codeforces, etc.).

๐Ÿ™ Acknowledgments

  • CSES Team for creating this amazing problem set
  • Competitive Programming Community for continuous learning
  • Open Source Contributors who share their knowledge

๐Ÿ“ž Contact

  • 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

About

My solutions for CSES Problem Set.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published