you n bag number 0 n 1 you give 0indexed integer array capacity rock the ith bag hold maximum capacityi rock currently contain rocksi rock you give integer additionalrock number additional rock place bagsreturn maximum number bag capacity place additional rock bag Example 1input capacity 2345 rock 1244 additionalrock 2Output 3ExplanationPlace 1 rock bag 0 1 rock bag 1the number rock bag 2344bags 0 1 2 capacitythere 3 bag capacity return 3it show possible 3 bag capacitynote way place rock result answer 3example 2input capacity 1022 rock 220 additionalrock 100Output 3ExplanationPlace 8 rock bag 0 2 rock bag 2the number rock bag 1022bags 0 1 2 capacitythere 3 bag capacity return 3it show possible 3 bag capacitynote use additional rock Constraintsn capacitylength rockslength1 n 5 1041 capacityi 1090 rocksi capacityi1 additionalrock 109