Count number of 1 s in the array after N moves | 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 ; Initialize array size ; Initialize all elements to 0
function perfectSquares ( a , b ) { return ( Math . floor ( Math . sqrt ( b ) ) - Math . ceil ( Math . sqrt ( a ) ) + 1 ) ; } function countOnes ( arr , n ) { return perfectSquares ( 1 , n ) ; } var N = 10 ; var arr = [ 0 ] ; document . write ( countOnes ( arr , N ) ) ;