Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Written by Prashant Basnet
π Welcome, Youβve Landed on My Signature Page.
Iβm a Software Development Engineer passionate about building scalable systems and solving problems.
Beyond engineering, I enjoy sharing ideas and documenting lessons so others can learn and build on them.This space is my digital notebook, a place where I reflect on what Iβm learning and creating.
π Problem Restatement (in simpler terms)
You are given:
π§ What is a path?
A path is a sequence of nodes:
Now suppose the colors string is:
colors = "abaca" β so:
And your edges are:
Letβs pick a path:
On this path, the colors are:
So the color frequency for this path is:
β What this does imply:
β Example:
Letβs say:
Instead of tracking that whole path, you just do:
π§ Why not 1D array ?
β οΈ The core issue:
π§ͺ Example to show why 1D fails:
Letβs say:
Suppose two paths go to node 2:
But:
β Why 2D works:
π§ Analogy:
Think of it like tracking the highest GPA in every subject per student:
Final Space Complexity:
Because 26 is constant β drops out in Big-O notation.
Final Time Compelxity: