Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You are given a positive integer ** ‘n’**.

Your task is to find and return its square root. If ‘n’ is not a perfect square, then return the floor value of sqrt(n).

```
Input: ‘n’ = 7
Output: 2
Explanation:
The square root of the number 7 lies between 2 and 3, so the floor value is 2.
```

Detailed explanation

```
6
```

```
2
```

```
The square root of the given number 6 lies between 2 and 3, so the floor value is 2.
```

```
100
```

```
10
```

```
The square root of the given number 100 is 10.
```

```
Try solving this in O(log(n)).
```

```
0 <= n <= 10 ^ 9
Time Limit: 1 sec.
```