Javascript implementation of the approach
let MAX = 101 ; let prefix = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { prefix [ i ] = new Array ( MAX ) . fill ( 0 ) } let ar = new Array ( MAX ) . fill ( 0 ) ;