mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										41
									
								
								算法题(国外版)/keep-multiplying-found-values-by-two.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								算法题(国外版)/keep-multiplying-found-values-by-two.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
<p>You are given an array of integers <code>nums</code>. You are also given an integer <code>original</code> which is the first number that needs to be searched for in <code>nums</code>.</p>
 | 
			
		||||
 | 
			
		||||
<p>You then do the following steps:</p>
 | 
			
		||||
 | 
			
		||||
<ol>
 | 
			
		||||
	<li>If <code>original</code> is found in <code>nums</code>, <strong>multiply</strong> it by two (i.e., set <code>original = 2 * original</code>).</li>
 | 
			
		||||
	<li>Otherwise, <strong>stop</strong> the process.</li>
 | 
			
		||||
	<li><strong>Repeat</strong> this process with the new number as long as you keep finding the number.</li>
 | 
			
		||||
</ol>
 | 
			
		||||
 | 
			
		||||
<p>Return <em>the <strong>final</strong> value of </em><code>original</code>.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [5,3,6,1,12], original = 3
 | 
			
		||||
<strong>Output:</strong> 24
 | 
			
		||||
<strong>Explanation:</strong> 
 | 
			
		||||
- 3 is found in nums. 3 is multiplied by 2 to obtain 6.
 | 
			
		||||
- 6 is found in nums. 6 is multiplied by 2 to obtain 12.
 | 
			
		||||
- 12 is found in nums. 12 is multiplied by 2 to obtain 24.
 | 
			
		||||
- 24 is not found in nums. Thus, 24 is returned.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [2,7,9], original = 4
 | 
			
		||||
<strong>Output:</strong> 4
 | 
			
		||||
<strong>Explanation:</strong>
 | 
			
		||||
- 4 is not found in nums. Thus, 4 is returned.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= nums.length <= 1000</code></li>
 | 
			
		||||
	<li><code>1 <= nums[i], original <= 1000</code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user