Product of all non repeating Subarrays of an Array | Java program to find the product of all non - repeating Subarrays of an Array ; Function to find the product of all non - repeating Subarrays of an Array ; Finding the occurrence of every element ; Iterating through the array and finding the product ; We are taking the power of each element in array with the occurrence and then taking product of those . ; Driver code
public class GFG { private static long product ( int [ ] arr ) { double occurrence = Math . pow ( 2 , arr . length - 1 ) ; double product = 1 ; for ( int i = 0 ; i < arr . length ; i ++ ) { product *= Math . pow ( arr [ i ] , occurrence ) ; } return ( long ) product ; } public static void main ( String [ ] args ) { int [ ] arr = { 10 , 3 , 7 } ; System . out . println ( product ( arr ) ) ; } }