Check if an array can be split into subarrays with GCD exceeding K | C # program for the above approach ; Function to check if it is possible to split an array into subarrays having GCD at least K ; Iterate over the array [ ] arr ; If the current element is less than or equal to k ; If no array element is found to be less than or equal to k ; Driver code ; Given array [ ] arr ; Length of the array ; Given K ; Function call
using System ; class GFG { static String canSplitArray ( int [ ] arr , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] <= k ) { return " No " ; } } return " Yes " ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 6 , 1 , 8 , 16 } ; int N = arr . Length ; int K = 3 ; Console . WriteLine ( canSplitArray ( arr , N , K ) ) ; } }