<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Binary Search on Jeanphilo Blog</title><link>https://jeanphilogong.github.io/jeanblog/tags/binary-search/</link><description>Recent content in Binary Search on Jeanphilo Blog</description><generator>Hugo -- 0.168.0</generator><language>en-us</language><lastBuildDate>Thu, 13 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://jeanphilogong.github.io/jeanblog/tags/binary-search/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 74: Search a 2D Matrix</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/74-search-a-2d-matrix/</link><pubDate>Thu, 13 Aug 2026 00:00:00 +0000</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/74-search-a-2d-matrix/</guid><description>&lt;p&gt;You are given an &lt;code&gt;m x n&lt;/code&gt; integer matrix &lt;code&gt;matrix&lt;/code&gt; and an integer &lt;code&gt;target&lt;/code&gt;. Return &lt;code&gt;True&lt;/code&gt; if &lt;code&gt;target&lt;/code&gt; is in the matrix; otherwise, return &lt;code&gt;False&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The matrix satisfies two conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Every row is sorted in non-decreasing order.&lt;/li&gt;
&lt;li&gt;The first integer of each row is strictly greater than the last integer of the previous row.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The required time complexity is &lt;code&gt;O(log(m * n))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For example, consider this matrix:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;1 3 5 7
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;10 11 16 20
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;23 30 34 60
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;When &lt;code&gt;target = 3&lt;/code&gt;, return &lt;code&gt;True&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;target = 13&lt;/code&gt;, return &lt;code&gt;False&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The constraints are:&lt;/p&gt;</description></item><item><title>LeetCode 153: Find Minimum in Rotated Sorted Array</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/153-find-minimum-in-rotated-sorted-array/</link><pubDate>Tue, 28 Jul 2026 16:13:57 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/153-find-minimum-in-rotated-sorted-array/</guid><description>Start from a linear scan, derive a closed minimum-containing interval, and return the rotated array&amp;#39;s minimum in O(log n) time and O(1) auxiliary space.</description></item><item><title>LeetCode 33: Search in Rotated Sorted Array</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/33-search-in-rotated-sorted-array/</link><pubDate>Tue, 28 Jul 2026 15:40:34 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/33-search-in-rotated-sorted-array/</guid><description>Derive sorted-half recognition and target-range tests from a linear baseline to search a rotated array in O(log n) time and O(1) auxiliary space.</description></item><item><title>LeetCode 2089: Find Target Indices After Sorting Array ACERS Guide</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/2089-find-target-indices-after-sorting-array/</link><pubDate>Wed, 18 Mar 2026 13:49:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/2089-find-target-indices-after-sorting-array/</guid><description>Sort the array, locate the target block with lower and upper bounds, and return every target index, with tradeoff analysis, engineering mappings, and runnable implementations in six languages.</description></item><item><title>LeetCode 2529: Maximum Count of Positive Integer and Negative Integer ACERS Guide</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/2529-maximum-count-of-positive-integer-and-negative-integer/</link><pubDate>Wed, 18 Mar 2026 13:49:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/2529-maximum-count-of-positive-integer-and-negative-integer/</guid><description>Count negatives and positives in a sorted array by locating the boundaries around zero with lower-bound and upper-bound binary search, with engineering mappings and runnable implementations in six languages.</description></item><item><title>LeetCode 34: Find First and Last Position of Element in Sorted Array</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/34-find-first-and-last-position-of-element-in-sorted-array/</link><pubDate>Wed, 18 Mar 2026 13:49:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/34-find-first-and-last-position-of-element-in-sorted-array/</guid><description>Start from a linear-scan baseline, derive two half-open binary-search boundaries, and return the complete target range in O(log n) time.</description></item><item><title>LeetCode 35: Search Insert Position Lower-Bound Binary Search ACERS Guide</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/35-search-insert-position/</link><pubDate>Wed, 18 Mar 2026 13:49:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/35-search-insert-position/</guid><description>Find the insertion index of a target in a sorted array with lower-bound binary search in O(log n), with boundary reasoning, engineering mappings, and runnable implementations in six languages.</description></item><item><title>LeetCode 744: Find Smallest Letter Greater Than Target Upper-Bound ACERS Guide</title><link>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/744-find-smallest-letter-greater-than-target/</link><pubDate>Wed, 18 Mar 2026 13:49:55 +0800</pubDate><guid>https://jeanphilogong.github.io/jeanblog/alg/leetcode/binary-search/744-find-smallest-letter-greater-than-target/</guid><description>Find the smallest character strictly greater than a target in a sorted circular array by using upper-bound binary search and wrap-around logic, with pitfalls, engineering mappings, and runnable implementations in six languages.</description></item></channel></rss>