Help me in the code part,I am not getting correct ans

Help me in the code part,I am not getting correct ans

Hey @samardeep
Please share the question

Question: Sum of minimum number of subsets equal to or greater than K(you can use the elements as many times as they are given in array). Input:first line contains n and k,second line contains n number of elements. 6 15 2 4 5 6 7 8 ans : 2 explanation : 7+8=15 i.e minimum no of elements. also 4+5+6 =15 but minimum no is 2 (7,8) help me with the code, I am not able to get correct ans

Hey @samardeep
Is it discussed in the lecture ?
Because this can be solved with greedy approach
Sort and start picking from largest

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.