Week 6 Day 5: The Grand Finale - Hard Problems
We made it! 30 days of math. Today, we look at three βFinal Bossβ problems that mix concepts.
Problem 1: The Doomsday Fuel (Probability + Matrices)
Task: Given a graph representing states of matter (some stable, some unstable), and transition probabilities. If you start at state $0$, what is the probability of ending in each stable state?
Solution: This is an Absorbing Markov Chain.
- Identify Absorbing States (Stable) and Transient States.
- Write the Transition Matrix in canonical form: $$ P = \begin{bmatrix} I & 0 \ R & Q \end{bmatrix} $$
- Calculate the Fundamental Matrix $F = (I - Q)^{-1}$. (Use Matrix Inverse via Gaussian Elimination).
- Calculate $FR$. This gives the probabilities of being absorbed in each stable state.
Concepts: Probability, Matrix Operations, Modular Inverse (if asked modulo P).
Problem 2: Visible Lattice Points (Number Theory + Geometry)
Task: You are at $(0,0,0)$ in a 3D grid of size $N \times N \times N$. How many integer points $(x, y, z)$ are visible from the origin? (A point is invisible if blocked by another point).
Solution: A point $(x, y, z)$ is visible if $\text{GCD}(x, y, z) = 1$. We need to count triplets with GCD 1. Use Mobius Inversion (Advanced Inclusion-Exclusion). $$ \sum_{g=1}^N \mu(g) \lfloor \frac{N}{g} \rfloor^3 $$
Concepts: GCD, Inclusion-Exclusion, Mobius Function.
Problem 3: Area of Union of Rectangles (Geometry + Data Structs)
Task: Given $N$ rectangles, find the area of their union. Solution:
- This is a Sweep Line problem.
- Sort vertical edges by x-coordinate.
- Move a vertical line from left to right.
- Maintain the βactiveβ y-intervals using a Segment Tree.
- Area += length_covered_by_active_intervals $\times$ dx.
Concepts: Geometry, Sorting, Segment Trees.
π The Graduation
You have completed the 6-Week Math Roadmap. You now possess a toolkit that puts you ahead of 90% of competitors:
- β Number Theory: Primes, CRT, Totient.
- β Combinatorics: nCr, Catalan, Stars & Bars.
- β Probability: Expectation, Randomization.
- β Geometry: Vectors, Hulls.
Whatβs Next?
Go to LeetCode or Codeforces and filter by tag Math.
Smash those problems. Happy Coding! π
π Series Complete!
You have finished the Maths roadmap.
π Next Challenge: MongoDB Roadmap