mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-20 23:41:00 +00:00
deploy
This commit is contained in:
@@ -5124,7 +5124,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<h3 id="2-converting-to-element-search">2. Converting to Element Search<a class="headerlink" href="#2-converting-to-element-search" title="Permanent link">¶</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>
|
||||
|
||||
Reference in New Issue
Block a user