dsa1 min read
Valid Perfect Square — Binary Search or Math
Check if a number is a perfect square in O(log n) using binary search or by exploiting odd-number sum identity.
Read →
1575 articles
Check if a number is a perfect square in O(log n) using binary search or by exploiting odd-number sum identity.
Find the smallest letter in a circular sorted list that is greater than the target using left-boundary binary search.
Answer election queries for who is leading at time t by precomputing the leader at each vote and binary searching.
Find the duplicate in array of n+1 integers in [1,n] using binary search on value with count-of-smaller logic.
Find the kth smallest prime fraction from an array using binary search on the fraction value with a counting function.