Substring sum
CodeChefOpen on judge ↗
Given a string S made of digits only, generate all possible substrings and convert them to numbers. Find sum of all such possible numbers. For example if S = '0102'. Then all possible substrings are ['0','1','0','2','01','10','02','010','102','0102']. Converting them into numbers result into [0, 1, 0 , 2, 1, 10, 2, 10, 102, 102] Sum of all these numbers is 230. Since result may be huge print it
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