C ++ code implementation of the above approach
#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 " ; }