Find if k bookings possible with given arrival and departure times | C ++ code implementation of the above approach ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string areBookingsPossible ( int A [ ] , int B [ ] , int K , int N ) { sort ( A , A + N ) ; sort ( B , B + N ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( i + K < N && A [ i + K ] < B [ i ] ) { return " No " ; } } return " Yes " ; } int main ( ) { int arrival [ ] = { 1 , 2 , 3 } ; int departure [ ] = { 2 , 3 , 4 } ; int N = sizeof ( arrival ) / sizeof ( arrival [ 0 ] ) ; int K = 1 ; cout << ( areBookingsPossible ( arrival , departure , K , N ) ) ; return 0 ; }