bhai yrr ek request h, background me bahott noice aati h try kro room ke gate and window bnd krke record kro ya mic thoda paas rakho agr still aae noice backgound ki to raat me record krke mon/sun - raat me upload krdo no issue
In 4th question, we can have a more intuitive approach. We will have index, no of subarrays to be taken and a boolean state representing whether atleast one element has been taken for formation of current subarray or not. Now, based on that boolean state we have following transition Also instead of thinking in terms of sum, the sum can be resolved to individual elements and the coeffients they were going to be multiplied with. Like this: (a + b + c) * x == a*x + b*x + c*x Now we only need to worry whether we want to include current element in subarray or start a new subarray from current element or entirely skip the current element. Note that boolean variable is necessary because if we have selected atleast one element in current subarray then we can't do the skip operation. Because, this would result in a subsequence formation. Including a boolean state allows us to alter the position of starting element of each subarray. This will be the states of dp, now each time return the min ans possible.