← All problemsSign in

Color the Tree!

Rohit likes to play with trees. His mother brought him water colors as christmas gift. He now plans to color his trees. However, Rohit wishes to follow a few rules for coloring his tree. He can either color a node as red or as blue. The cost of coloring a node is defined as: 1. If Rohit colors a node as red, then the total cost incurred for coloring that node is equal to (total number of direct

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start