Software Engineer's Blog

Blog posts — page 35

Why is Binary Search O(log n)?

Coding Interview

Why is Binary Search O(log n)?

Jason Yang · 02 Dec, 2025

Binary Search runs in O(log n) because it halves the search space every step. Here's the intuition, the math proof, and how it compares to linear search.

153. Find Minimum in Rotated Sorted Array

Coding Interview

153. Find Minimum in Rotated Sorted Array

Jason Yang · 02 Dec, 2025

Find Minimum in Rotated Sorted Array (LeetCode 153): the O(log n) binary search that locates the rotation pivot, explained step by step with examples.

152. Maximum Product Subarray

Coding Interview

152. Maximum Product Subarray

Jason Yang · 01 Dec, 2025

Maximum Product Subarray (LeetCode 152): why you track max and min together to handle negatives and zeros, and the O(n) dynamic-programming solution.