Find the answer to the current element
let cur = AToi . get ( A [ i ] ) ; let l = mp . get ( cur ) [ 0 ] ; let r = mp . get ( cur ) [ 1 ] ; if ( l >= 0 && r < N ) { m = Math . min ( ans [ l ] , ans [ r ] ) + 1 ; } else if ( l < 0 && r < N ) { m = ans [ r ] + 1 ; } else if ( l >= 0 && r >= N ) { m = ans [ l ] + 1 ; }