Lookup for upperbound of ( cSum - K ) in hash
ArrayList < Integer > al = new ArrayList < > ( ) ; Iterator < Integer > it = cum_set . iterator ( ) ; int end = 0 ; while ( it . hasNext ( ) ) { end = it . next ( ) ; al . add ( end ) ; } Collections . sort ( al ) ; int sit = lower_bound ( al , cSum - K ) ;