Approach hintTry it first, then revealHide
Let dp[v] be the fewest letter changes needed to reach a leaf from v. Going to the left child costs one change unless s[v] is L, and similarly for the right child; a leaf costs nothing.
Let dp[v] be the fewest letter changes needed to reach a leaf from v. Going to the left child costs one change unless s[v] is L, and similarly for the right child; a leaf costs nothing.