Practice & Problem Solving
Master competitive programming through coding challenges and develop algorithmic thinking with logic puzzles.
Coding Problems
Practice with curated problems from Codeforces, organized by difficulty. Build your skills from beginner to advanced.
Coding Tips
- Start with problems at your current skill level, then gradually increase difficulty
- Try to solve each problem on your own before looking at hints or solutions
- After solving, analyze the time and space complexity of your solution
- Revisit problems you couldn't solve after learning new concepts
Beginner Problems
Perfect for those just starting their competitive programming journey.
Watermelon
BeginnerWay Too Long Words
BeginnerTeam
BeginnerNext Round
BeginnerEasy Problems
Build confidence with basic algorithmic thinking.
Nearly Lucky Number
EasyPetya and Strings
EasyBear and Big Brother
EasyElephant
EasyMedium Problems
Challenge yourself with sorting, searching, and simulation problems.
Twins
MediumQueue at the School
MediumTwo-gram
MediumGravity Flip
MediumHard Problems
Advanced algorithms, graphs, and dynamic programming.
Longest Regular Bracket Sequence
HardTwo Buttons
HardMike and Shortcuts
HardPowerful Array
HardMore Practice Resources
Explore these platforms for additional problems.
Logic & Reasoning
Develop algorithmic thinking through puzzles. No coding required — focus on problem-solving strategies.
Problem Solving Framework
Understand
Identify inputs, outputs, constraints
Plan
Break into smaller parts
Explore
Try examples, find patterns
Solve
Design step-by-step approach
Reflect
Optimize and learn
Classic Logic Puzzles
Foundational puzzles that teach core problem-solving patterns.
The Weighing Problem
Binary SearchProblem
You have 8 identical-looking balls. One ball is slightly heavier than the others. Using a balance scale, what is the minimum number of weighings needed to guarantee finding the heavy ball?
Think about dividing balls into groups. Each weighing gives three outcomes: left heavier, right heavier, or balanced.
Answer: 2 weighings
Approach: Divide and Conquer (Ternary Search)
- Divide into 3 groups: A(3), B(3), C(2)
- Weighing 1: Compare A vs B → identifies which group has heavy ball
- Weighing 2: Compare 2 balls from that group → finds the heavy one
Key Insight: With n weighings, you can distinguish 3ⁿ cases. 3² = 9 ≥ 8 balls.
Water Jug Problem
State Space SearchProblem
You have a 5-liter jug and a 3-liter jug with no measuring marks. How do you measure exactly 4 liters of water?
Think of each state as (water in 5L, water in 3L). What operations can you perform?
Solution Steps
Key Insight: This is a graph problem! BFS finds the shortest path.
Monty Hall Problem
ProbabilityProblem
3 doors: one has a car, two have goats. You pick a door. The host opens another door showing a goat. Should you switch or stay?
What's the probability the car was behind your first choice? What about the other doors combined?
Always Switch! (2/3 win rate)
Case Analysis:
- Pick car (1/3) → Switch loses
- Pick goat A (1/3) → Switch wins
- Pick goat B (1/3) → Switch wins
Key Insight: Your initial choice had 1/3 probability. The remaining 2/3 concentrates on the other unopened door.
Algorithmic Thinking
Problems about efficiency, optimization, and algorithm design.
The Staircase Problem
Dynamic ProgrammingProblem
You can climb stairs by taking 1 or 2 steps at a time. How many different ways can you climb n steps?
To reach step n, you must have come from n-1 or n-2. How do these relate?
Answer: Fibonacci Sequence!
Key Insight: This is dynamic programming — combining solutions to subproblems.
Find the Missing Number
Mathematical InsightProblem
You have n-1 distinct integers from 1 to n (one missing). Find it in O(n) time and O(1) space without sorting.
You know what the sum of 1 to n should be...
Use the Sum Formula
Alternative: XOR all numbers 1 to n with all elements. Result = missing number.
Coin Change Greedy Trap
Greedy vs DPProblem
Coins: [1, 3, 4]. What's the minimum coins for 6 cents? Does greedy (always pick largest) work?
Greedy: pick 4, then what? Try 3+3 instead.
Greedy Fails! Answer: 2 coins
Greedy: 4 + 1 + 1 = 3 coins ❌
Optimal: 3 + 3 = 2 coins ✓
Lesson: Greedy doesn't always work. When in doubt, use DP.
Strategy & Optimization
Making optimal decisions and understanding trade-offs.
The Egg Drop Problem
OptimizationProblem
2 eggs, 100 floors. Find the highest safe floor. What's the minimum drops needed in worst case?
If egg breaks at floor k, you have 1 egg for floors 1 to k-1 (linear search). Balance worst cases!
Answer: 14 drops
Drop from floors: 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100
Each step decreases by 1 because you've used one drop.
Math: n + (n-1) + ... + 1 ≥ 100 → n = 14
River Crossing Puzzle
Constraint SatisfactionProblem
Farmer with wolf, goat, cabbage. Boat fits farmer + 1 item. Wolf eats goat, goat eats cabbage if left alone. Get all across safely.
The goat can't be left with either. Sometimes you need to bring something back!
7 Crossings
Key Insight: Backtracking is necessary!
Tower of Hanoi
RecursionProblem
3 pegs, n disks on peg A (smallest on top). Move all to C. Rules: move one at a time, never place larger on smaller. Minimum moves?
To move n disks A→C: First move top (n-1) to B, then bottom to C, then (n-1) from B to C.
Answer: 2ⁿ - 1 moves
Recurrence: T(n) = 2T(n-1) + 1
n=1: 1 | n=2: 3 | n=3: 7 | n=4: 15 | n=5: 31
Key Insight: Classic example of recursive problem decomposition.