dp [ i ] [ j ] be the longest subsequence of a [ 0. . . i ] with first j parts
var dp = Array . from ( Array ( 4 ) , ( ) => Array ( n ) . fill ( 0 ) ) ; if ( arr [ 0 ] == 0 ) dp [ 0 ] [ 0 ] = 1 ; else dp [ 1 ] [ 0 ] = 1 ;