Skip to content

Instantly share code, notes, and snippets.

View jgsanchezg's full-sized avatar

Jesus Sanchez jgsanchezg

  • Mexico City, Mexico
View GitHub Profile
@mksglu
mksglu / perfectsquare.js
Last active November 25, 2020 22:50
Binary Search
/*
1. Initialize left=1 & Right=n
2. Calculate mid = Math.floor((left + right) / 2);
2. If mid*mid = n, then n is Perfect Square
3. Else if mid*mid > n then right = mid - 1
4. Else if mid*mid < n then left = mid + 1
*/
const perfectSquare = (number) => {