/**
 * Returns a longest increasing subsequence of the given array 'x' in O(n log n) time.
 *  https export function lis ( x ) { if ( ! x . length ) { return x ; } const m = [ 0 ] ; const p = new Array < number > ( x . length ) ; for ( let i = 1 ; i < x . length ; i ++ ) { { const mj = m [ m . length - 1 ] ; if ( x [ mj ] < x [ i ] ) { p [ i ] = mj ; m . push ( i ) ; continue ; } } let lo = 0 ; { let hi = m . length - 1 ; while ( lo < hi ) { const mid = ( lo + hi ) >>> 1 ; if ( x [ m [ mid ] ] < x [ i ] ) { lo = mid + 1 ; } else { hi = mid ; } } } if ( x [ i ] < x [ m [ lo ] ] ) { if ( lo ) { p [ i ] = m [ lo - 1 ] ; } m [ lo ] = i ; } } for ( let j = m . length , mj = m [ j - 1 ] ; j -- ; mj = p [ mj ] ) { m [ j ] = x [ mj ] ; } return m ; }