For the length of strictly larger numbers on the left of A [ i ]
for ( let i = 0 ; i < N ; i ++ ) { let count = 1 ; while ( l . length != 0 && l [ l . length - 1 ] [ 0 ] > arr [ i ] ) { count += l [ l . length - 1 ] [ 1 ] ; l . pop ( ) ; } l . push ( [ arr [ i ] , count ] ) ;