mirror of
https://github.com/krahets/hello-algo.git
synced 2026-09-22 14:26:34 +08:00
deploy
This commit is contained in:
@@ -3597,7 +3597,7 @@
|
||||
<p>Given an integer array <code>nums</code> and a target element <code>target</code>, please search for two elements in the array whose "sum" equals <code>target</code>, and return their array indices. Any solution is acceptable.</p>
|
||||
</div>
|
||||
<h2 id="1041-linear-search-trading-time-for-space">10.4.1 Linear search: trading time for space<a class="headerlink" href="#1041-linear-search-trading-time-for-space" title="Permanent link">¶</a></h2>
|
||||
<p>Consider traversing all possible combinations directly. As shown in the Figure 10-9 , we initiate a two-layer loop, and in each round, we determine whether the sum of the two integers equals <code>target</code>. If so, we return their indices.</p>
|
||||
<p>Consider traversing all possible combinations directly. As shown in Figure 10-9, we initiate a two-layer loop, and in each round, we determine whether the sum of the two integers equals <code>target</code>. If so, we return their indices.</p>
|
||||
<p><a class="glightbox" href="../replace_linear_by_hashing.assets/two_sum_brute_force.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Linear search solution for two-sum problem" class="animation-figure" src="../replace_linear_by_hashing.assets/two_sum_brute_force.png" /></a></p>
|
||||
<p align="center"> Figure 10-9 Linear search solution for two-sum problem </p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user