Leetcode Problem 2154. Keep Multiplying Found Values by Two

2154. Keep Multiplying Found Values by Two

Leetcode Solutions

HashSet Approach

  1. Create a HashSet and add all elements from the nums array to it.
  2. Use a while loop to check if the original value is present in the HashSet.
  3. If original is found, double its value.
  4. If original is not found, break out of the loop.
  5. Return the final value of original.
UML Thumbnail

Sorting and Searching Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...