Check whether the product of every subsequence is a perfect square or not | Java program for the above approach ; Function to check if the product of every subsequence of the array is a perfect square or not ; Traverse the given array ; If arr [ i ] is a perfect square or not ; Return " Yes " ; Driver Code
import java . io . * ; class GFG { static String perfectSquare ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int p = ( int ) Math . sqrt ( arr [ i ] ) ; if ( p * p != arr [ i ] ) { return " No " ; } } return " Yes " ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 100 } ; int N = arr . length ; System . out . println ( perfectSquare ( arr , N ) ) ; } }