String Power
Chef has been recently studying strings and probabilities and he came up with a problem for you. Consider an alphabet with $N$ characters (denoted by $c_1, c_2, \ldots, c_N$). For each valid $i$, the character $c_i$ has a *power* $a_i$; the power of a string that contains only characters from this alphabet is the sum of their powers (if a character occurs multiple times, its power also occurs i
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.
Sign in to chat with the tutor and save your progress.
Sign in to start