Find two non | Java program for the above approach ; Function to check if two non - intersecting subarrays with equal sum exists or not ; Sort the given array ; Traverse the array ; Check for duplicate elements ; If no duplicate element is present in the array ; Driver code ; Given array ; Size of array
import java . util . * ; class GFG { static void findSubarrays ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; int i = 0 ; for ( i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { System . out . println ( " YES " ) ; return ; } } System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 3 , 0 , 1 , 2 , 0 } ; int N = arr . length ; findSubarrays ( arr , N ) ; } }