Here array keys [ ] is assumed to be sorted in increasing order . If keys [ ] is not sorted , then add code to sort keys , and rearrange freq [ ] accordingly .
return optCost ( freq , 0 , n - 1 ) NEW_LINE