Consider a sample space S consisting of all perfect squares starting from 1, 4, 9 and so on. You are given a number N, you have to output the number of integers less than N in the sample space S.
 
Example 1:
Input :
N = 9
Output:
2
Explanation:
1 and 4 are the only Perfect Squares
less than 9. So, the Output is 2.
Example 2:
Input :
N = 3
Output:
1
Explanation:
1 is the only Perfect Square
less than 3. So, the Output is 1.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function countSquares() which takes an Integer N as input and returns the answer.
 
Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{8}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def countSquares(self, N):
        # code here 

Solutions:
import math

class Solution:

	def countSquares(self, N):
		s = math.sqrt(N)
		if N == 0 or N == 1:
			return 0
		elif N < 0:
			return 0
		elif N == int(s) ** 2 and N % int(s) == 0:
			return int(s) - 1
		else:
			return int(s) + 1 - 1


import math

class Solution:

	def countSquares(self, N):
		count = int(math.sqrt(N - 1))
		return count


class Solution:

	def countSquares(self, N):
		return int((N - 1) ** 0.5)


class Solution:

	def countSquares(self, N):
		if N == int(N ** 0.5) ** 2:
			return int(N ** 0.5) - 1
		return int(N ** 0.5)


class Solution:

	def countSquares(self, N):
		return int(math.sqrt(N - 1))


class Solution:

	def countSquares(self, N):
		a = math.sqrt(N - 1)
		b = int(a)
		return b


class Solution:

	def countSquares(self, n):
		return int(math.sqrt(n - 1))


import math

class Solution:

	def countSquares(self, N):
		r = math.sqrt(N)
		if r.is_integer():
			return int(r - 1)
		else:
			return int(r)


import math

class Solution:

	def countSquares(self, N):
		m = 0
		m = math.sqrt(N)
		N = int(math.sqrt(N))
		if m - N == 0:
			return N - 1
		else:
			return N


import math

class Solution:

	def countSquares(self, N):
		if N == int(math.sqrt(N)) ** 2:
			return int(N ** 0.5) - 1
		return int(N ** 0.5)


import math

class Solution:

	def countSquares(self, N):
		return math.floor(math.sqrt(N - 1))


class Solution:

	def countSquares(self, N):
		(l, r) = (1, N)
		res = 1
		while l <= r:
			mid = (l + r) // 2
			if mid * mid == N:
				return mid - 1
			elif mid * mid <= N:
				res = mid
				l = mid + 1
			else:
				r = mid - 1
		return res


import math

class Solution:

	def countSquares(self, n):
		return math.floor(math.sqrt(n - 1))


import math

class Solution:

	def countSquares(self, N):
		count = 0
		count = math.floor(math.sqrt(N))
		if count * count == N:
			return count - 1
		else:
			return count


class Solution:

	def countSquares(self, N):
		import math
		if int(N) == int(math.sqrt(N)) ** 2:
			return len(range(1, round(math.sqrt(N))))
		return int(math.sqrt(N))


class Solution:

	def countSquares(self, N):
		a = N ** 0.5
		b = math.ceil(a)
		return b - 1


class Solution:

	def countSquares(self, N):
		c = 0
		d = int(N ** (1 / 2))
		if d * d == N:
			return d - 1
		return d


import math

class Solution:

	def countSquares(self, N):
		n = N ** 0.5
		if n - int(n) == 0:
			return int(n - 1)
		else:
			return int(n)


class Solution:

	def countSquares(self, N):
		k = int(math.sqrt(N))
		if k * k == N:
			return k - 1
		else:
			return int(k)


class Solution:

	def countSquares(self, N):
		(start, end) = (0, N - 1)
		root = -1
		while start <= end:
			mid = start + (end - start) // 2
			if mid ** 1 * mid < N ** 1:
				root = mid
				start = mid + 1
			else:
				end = mid - 1
		return root


import math

class Solution:

	def countSquares(self, N):
		return int((N - 1) ** 0.5)


import math

class Solution:

	def countSquares(self, N):
		res = math.ceil(math.sqrt(N))
		return res - 1


from math import sqrt, ceil

class Solution:

	def countSquares(self, N):
		ans = ceil(sqrt(N))
		return ans - 1


class Solution:

	def countSquares(self, N):
		return int(math.sqrt(N - 1))
		count = 0
		for i in range(1, int(math.sqrt(N) + 1)):
			if i * i < N:
				count += 1
		return count


class Solution:

	def countSquares(self, N):
		n = N ** (1 / 2)
		if n > int(n):
			return int(n)
		else:
			return int(n) - 1


class Solution:

	def countSquares(self, N):
		n = N ** 0.5
		return math.ceil(n) - 1


class Solution:

	def countSquares(self, N):
		return int((N - 1) ** (1 / 2))


class Solution:

	def countSquares(self, N):
		N = N - 1
		r = N ** (1 / 2)
		k = int(r)
		if N == 0:
			return 0
		else:
			return k


import math

class Solution:

	def countSquares(self, n):
		square_root = int(math.sqrt(n))
		if square_root * square_root == n:
			return square_root - 1
		return square_root


class Solution:

	def countSquares(self, N):
		import math
		ans = math.sqrt(N)
		ans1 = int(ans)
		if ans - ans1 == 0:
			return ans1 - 1
		else:
			return ans1


class Solution:

	def countSquares(self, N):
		return math.ceil(math.sqrt(N)) - 1


class Solution:

	def countSquares(self, N):
		if N == 1:
			return 0
		l = 0
		h = N // 2
		while l <= h:
			m = (l + h) // 2
			if m * m > N:
				h = m - 1
			elif m * m == N:
				return m - 1
			elif (m + 1) * (m + 1) > N:
				return m
			else:
				l = m + 1


class Solution:

	def countSquares(self, N):
		val = N ** 0.5
		if val == int(val):
			return int(val) - 1
		else:
			return int(val)


class Solution:

	def countSquares(self, n):
		return math.ceil(math.sqrt(n)) - 1