Find if k bookings possible with given arrival and departure times | Java code implementation of the above approach ; Driver Code
import java . util . * ; class GFG { static String areBookingsPossible ( int [ ] A , int [ ] B , int K ) { Arrays . sort ( A ) ; Arrays . sort ( B ) ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( i + K < A . length && A [ i + K ] < B [ i ] ) { return " No " ; } } return " Yes " ; } public static void main ( String [ ] s ) { int [ ] arrival = { 1 , 2 , 3 } ; int [ ] departure = { 2 , 3 , 4 } ; int K = 1 ; System . out . print ( areBookingsPossible ( arrival , departure , K ) ) ; } }