you currently design dynamic array you give 0indexed integer array num numsi number element array time in addition give integer k maximum number times resize array sizethe size array time t sizet numst need space array hold element the space waste time t define sizet numst total space waste sum space waste time t 0 t numslengthreturn minimum total space waste resize array k timesnote the array size start count number resizing operation Example 1input num 1020 k 0Output 10explanation size 2020we set initial size 20The total waste space 20 10 20 20 10example 2input num 102030 k 1Output 10explanation size 202030we set initial size 20 resize 30 time 2 the total waste space 20 10 20 20 30 30 10example 3input num 1020153020 k 2Output 15explanation size 1020203030we set initial size 10 resize 20 time 1 resize 30 time 3the total waste space 10 10 20 20 20 15 30 30 30 20 15 Constraints1 numslength 2001 numsi 1060 k numslength 1