text: Choose X elements from A [ ] and Y elements from B [ ] which satisfy the given condition | C # implementation of the above approach ; Function to that returns true if it possible to choose the elements ; If elements can 't be chosen ; Sort both the arrays ; If xth smallest element of A [ ] is smaller than the yth greatest element of B [ ] ; Driver code
code: using System ; class GFG { static bool isPossible ( int [ ] A , int [ ] B , int n , int m , int x , int y ) { if ( x > n y > m ) return false ; Array . Sort ( A ) ; Array . Sort ( B ) ; if ( A [ x - 1 ] < B [ m - y ] ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 1 , 1 , 1 , 1 } ; int [ ] B = { 2 , 2 } ; int n = A . Length ; int m = B . Length ; ; int x = 3 , y = 1 ; if ( isPossible ( A , B , n , m , x , y ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }