Sum of all substrings of a string representing a number using dynamic programming

preview_player
Показать описание
Joey'sTech brings you a fantastic dynamic programming problem that is going to brush up your basics.
You may find it a mathematics marvel but you are going to solve it using the dynamic programming technique. Actually, you are going to figure out how
connected mathematics and dynamic programming are.

To get smarter at solving computing problems you need to solve the DP problems like these not once, not twice but many times.
Believe me each time you solve this DP problem not only you are going to learn something new but you are increasing your chances of clearing the tech interviews too.

So, let's deep dive in the problem statement now -

You are given a string that represents a number
"124"

Your ask is to find out the sum of all the substrings that emerge from this string.

So, the substrings are
1 + 2 + 12 + 4 + 24 + 124

The sum total is going to come out as 167.

We will construct a dynamic programming algorithm to solve this problem in my framework.
I promise that you are going to enjoy learning this problem thus, I need you to get hooked to the video till the end.

So, let's solve this DP problem together and take a step ahead on being the master of coding and algorithms.

-------------------------------------------------------

Also watch

-------------------------------------------------------

Weighted job scheduling problem

Longest common subsequence dynamic programming

How to magically find longest common substring

Find ugly numbers using dynamic programming

Step by step guide to solve the staircase problem
Рекомендации по теме
Комментарии
Автор

I usually don't comment on videos. But I tried watching many videos to understand the solution to this problem. But none of them explained like you. Thank you so much.

hardikrathore
Автор

It's great man!!!
Keep going ❤️

ashoknandurka
Автор

This solution fails for the string and many more cases? The best way to this problem is using masking of subsets, it will take O(2 ^ N * N) and it will work fine until 1 <= N <= 20;

SNX
visit shbcf.ru