This commit is contained in:
krahets
2026-08-18 03:09:26 +08:00
parent 0375f25b66
commit fde23f369e
158 changed files with 312 additions and 282 deletions
@@ -5124,7 +5124,7 @@
</div>
</div>
<h3 id="2-converting-to-element-search">2. &nbsp; Converting to Element Search<a class="headerlink" href="#2-converting-to-element-search" title="Permanent link">&para;</a></h3>
<p>We know that when the array does not contain <code>target</code>, <span class="arithmatex">\(i\)</span> and <span class="arithmatex">\(j\)</span> will eventually point to the first elements greater than and less than <code>target</code>, respectively.</p>
<p>We know that when the array does not contain <code>target</code>, <span class="arithmatex">\(i\)</span> and <span class="arithmatex">\(j\)</span> will eventually point to the first element greater than <code>target</code> and the rightmost element less than <code>target</code>, respectively.</p>
<p>Therefore, as shown in Figure 10-8, we can construct an element that does not exist in the array to find the left and right boundaries.</p>
<ul>
<li>Finding the leftmost <code>target</code>: This can be converted to finding <code>target - 0.5</code> and returning the pointer <span class="arithmatex">\(i\)</span>.</li>