DP - 12: Subset Sum Problem (If there exists a subset with sum equal to given sum)

preview_player
Показать описание
Solution:
- We need to check every subset whose sum is equal to given sum
- for every array value, there'll be two case, either we include the current value or we exclude the current value

Time Complexity: O(2^n)

DP Solution (Bottom Up):
- We initialise 2D array, which will check every combination
- We check if we exclude or include the the current value & if any one of both is true then it's true
- At last we return rightmost bottom value in given 2d array

Time Complexity: O(n^2)
Space Complexity: O(n^2)

Do Watch video for more info

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ Send us mail at: ★☆★
Рекомендации по теме
visit shbcf.ru