Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added solution to 0069_sqrt(x)
  • Loading branch information
pranjalkumar153 committed Oct 2, 2020
commit bce5ba779bee402cb7e36cc2467069127725f302
17 changes: 17 additions & 0 deletions LeetCode/0069 _ Sqrt(x).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution(object):
def mySqrt(self, x):
if x<2:
return x
low = 0
high = x
result=0
while(low<=high):
mid = (low+high)//2
if(mid*mid==x):
return mid
elif(mid*mid<x):
low = mid+1
result = mid
else:
high = mid-1
return result