Binary Search, Bits and Maths

Halve the search space on sorted data and answers, and use bit tricks and number theory to keep arithmetic fast.

  1. 01

    Binary Search

    • easy
    • Code
  2. 02

    Floor of a Square Root

    • easy
    • Code
  3. 03

    Single Number

    • easy
    • Code
  4. 04

    Count the Bits

    • easy
    • Code
  5. 05

    Power of Two

    • easy
    • Code
  6. 06

    Greatest Common Divisor and LCM

    • easy
    • Code
  7. 07

    Search a Rotated Sorted Array

    • medium
    • Code
  8. 08

    First and Last Index

    • medium
    • Code
  9. 09

    Search a 2D Matrix

    • medium
    • Code
    • Pro
  10. 10

    Koko Eating Bananas

    • medium
    • Code
    • Pro
  11. 11

    Count Primes Below N

    • medium
    • Code
  12. 12

    Fast Power Modulo

    • medium
    • Code