If sum is greater than K
if ( leftSum + rightSum > K ) break ; } } if ( leftTaken + rightTaken <= N ) { for ( int i = 0 ; i < leftTaken ; i ++ ) System . out . print ( A [ i ] + " ▁ " ) ; for ( int i = 0 ; i < rightTaken ; i ++ ) System . out . print ( A [ N - i - 1 ] + " ▁ " ) ; }