00:01
Hello students, the sum of subset problem can be solved using the backtracking algorithm.
00:07
The goal is to find all the subset of the given set whose elements add up to the specific target sum.
00:14
So, here is we are using the backtracking algorithm to find the subset of 5, 10, 12, 13, 15 as well as 18 and then adds up to the sum of an 30.
00:27
So, here in this code you can see we are using the sum of subset backtrack function is an recursive backtracking function that explores the different subset of the input array.
00:41
Fine? where it keeps the track of the current sum as well as the current index start and selected elements for the current subset.
00:53
So, if the current sum equals to the target sum, if it is an equals to the target sum where like it means that the valid subset has been found and it prints the selected elements.
01:07
Whereas, if the current sum exceeds the target sum or the end of the array is reached the function returns...