Given a number N, find the cube root of N.
Note: We need to print the floor value of the result.
 
Example 1:
Input:
N = 3
Output:
1
Explanation:
Cube root of 3 is 1.442 = 1
Example 2:
Input:
N = 8
Output:
2
Explanation:
Cube root of 8 is 2
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function cubeRoot() which takes a Integer N as input and returns the answer.
 
Expected Time Complexity: O(cube root of N)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def cubeRoot(self, N):

        # code here 

Solutions:
import math

class Solution:

	def cubeRoot(self, N):
		return math.floor(N ** (1 / 3))


class Solution:

	def cubeRoot(self, N):
		return int(pow(N, 1 / 3))


import math
import numpy as np

class Solution:

	def cubeRoot(self, N):
		return math.floor(np.cbrt(N))


import math

class Solution:

	def cubeRoot(self, N):
		a = math.pow(N, 1 / 3)
		return int(a)


import numpy as np

class Solution:

	def cubeRoot(self, N):
		return int(np.cbrt(N))


class Solution:

	def cubeRoot(self, N):
		m = int(N ** (1 / 3))
		return m


class Solution:

	def cubeRoot(self, N):
		x = N ** (1 / 3)
		return int(x)


class Solution:

	def cubeRoot(self, N):
		c = int(float(N) ** (1 / 3))
		return c


class Solution:

	def cubeRoot(self, N):
		i = N ** (1 / 3)
		I = int(i)
		return I


class Solution:

	def cubeRoot(self, N):
		a = int(N ** (1 / 3))
		return a


class Solution:

	def cubeRoot(self, N):
		if N == 1 or N == 0:
			return N
		ans = 1
		i = 1
		while ans < N:
			i += 1
			ans = i * i * i
		return i - 1


class Solution:

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


import math

class Solution:

	def cubeRoot(self, N):
		for i in range(1, N + 1):
			if i * i * i == N:
				return i
			elif i * i * i > N:
				return i - 1
			else:
				continue


class Solution:

	def cubeRoot(self, N):
		i = 0
		while i <= N:
			if i * i * i <= N:
				i += 1
				continue
			else:
				break
		return i - 1


class Solution:

	def cubeRoot(self, N):
		a = 1 / 3
		b = N ** a
		c = int(b)
		return c


class Solution:

	def cubeRoot(self, N):
		r = round(N ** (1 / 3), 6)
		return int(r)


class Solution:

	def cubeRoot(self, N):
		ans = int(N ** (1 / 3))
		return ans


class Solution:
	import math

	def cubeRoot(self, N):
		cube = int(N ** (1 / 3))
		return cube


class Solution:

	def cubeRoot(self, N):
		r = int(N ** (1 / 3))
		return r


class Solution:

	def cubeRoot(self, N):
		k = int(N ** (1 / 3))
		return k


from numpy import cbrt
import math

class Solution:

	def cubeRoot(self, N):
		return math.floor(cbrt(N))


class Solution:

	def diff(self, n, mid):
		if n > mid * mid * mid:
			return n - mid * mid * mid
		else:
			return mid * mid * mid - n

	def cubicr(self, n):
		if n == 1:
			return 1
		start = 0
		end = n
		e = 1e-07
		while True:
			mid = (start + end) / 2
			error = self.diff(n, mid)
			if error <= e:
				return mid
			if mid * mid * mid > n:
				end = mid
			else:
				start = mid

	def cubeRoot(self, N):
		return int(self.cubicr(N))


import math as m

class Solution:

	def cubeRoot(self, N):
		n = m.floor(N ** (1 / 3))
		return n


class Solution:

	def cubeRoot(self, N):
		n = int(N ** (1 / 3))
		return n


import math

class Solution:

	def cubeRoot(self, N):
		cube = N ** 0.3333333333333333
		return math.floor(cube)


class Solution:

	def cubeRoot(self, N):
		l = 0.0001
		s = 0
		e = N
		if N == 1:
			return 1
		while s < e:
			mid = (s + e) / 2
			c = mid * mid * mid
			if abs(c - N) <= l:
				return int(mid)
			if c > N:
				e = mid
			else:
				s = mid


import math

class Solution:

	def cubeRoot(self, n):
		return math.floor(pow(10, math.log10(n) / 3))


import math

class Solution:

	def cubeRoot(self, N):
		return math.trunc(N ** (1 / 3))


class Solution:

	def cubeRoot(self, N):
		res = int(N ** (1 / 3))
		return res