MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

SquareRootUsingBinarySearch.java:1–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 public int mySqrt(int x) {
3
4 int start=1;
5 int end=x;
6
7 while(start<=end)
8 {
9 int mid = start+(end-start)/2;
10 if(mid<=x/mid) start=mid+1;
11 else end=mid-1;
12 }
13 return end;
14 }
15}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected