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 to my Signature, a space between logic and curiosity.
Iβm a Software Development Engineer who loves turning ideas into systems that work beautifully.
This space captures the process: the bugs, breakthroughs, and βahaβ moments that keep me building.
π 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: