Count number of 1 s in the array after N moves | Java implementation of the above approach ; Function to count number of perfect squares ; Counting number of perfect squares between a and b ; Function to count number of 1 s in array after N moves ; Driver Code ; Initialize array size ; Initialize all elements to 0
import java . io . * ; class GFG { static double perfectSquares ( int a , int b ) { return ( Math . floor ( Math . sqrt ( b ) ) - Math . ceil ( Math . sqrt ( a ) ) + 1 ) ; } static double countOnes ( int arr [ ] , int n ) { return perfectSquares ( 1 , n ) ; } public static void main ( String [ ] args ) { int N = 10 ; int arr [ ] = { 0 } ; System . out . println ( countOnes ( arr , N ) ) ; } }