Counts 1 s that can be obtained in an Array by performing given operations | Java program to implement the above approach ; Function to count total number of 1 s in array by performing the given operations ; Stores count of 1 s in the array by performing the operations ; Update cntOnes ; Driver code
import java . util . * ; class GFG { static int cntOnesArrWithGivenOp ( int arr [ ] , int N ) { int cntOnes = 0 ; cntOnes = ( int ) Math . sqrt ( N ) ; return cntOnes ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int N = arr . length ; System . out . println ( cntOnesArrWithGivenOp ( arr , N ) ) ; } }