Skip to content

Commit

Permalink
Update 0069-sqrtx.js
Browse files Browse the repository at this point in the history
Using the Bitwise operator to get the middle value.
  • Loading branch information
aadil42 authored Jul 11, 2023
1 parent a898b71 commit 07dfbff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/0069-sqrtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var mySqrt = function(x) {
let right = x;

while(left <= right) {
const mid = left + Math.floor((right - left)/2);
const mid = (left + right) >> 1;
if(mid * mid <= x && (mid+1) * (mid+1) > x) return mid;
if(mid * mid < x) {
left = mid + 1;
Expand Down

0 comments on commit 07dfbff

Please sign in to comment.