Change all the elements in the range 0. . i to the most frequent element in this range
dp [ i ] [ 1 ] = ( i + 1 ) - freqOfMode ; } else { let freq = new Array ( 100000 ) ; for ( let i = 0 ; i < freq . length ; i ++ ) { freq [ i ] = 0 ; } let freqOfMode = 0 ;