Find Doubles
Updated
Problem statement
Given a list of N integers, not necessarily unique, find all elements of the list for which there exists exactly one element of the list which is twice that number. The integers range from 0 to 1000. The list has no more than 100,000 elements.
Your code should find the appropriate values and print them to STDOUT in sorted order.
Function
findDoubles(numbers: List<Integer>) → List<Integer>Examples
Example 1
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 8]return = [0, 1, 2, 3]
8 is 4*2, but 8 is present twice, 0 is its own double, so it's part of the result.
Example 2
numbers = [7, 17, 11, 1, 23]return = []Nothing is exactly twice another element.
Example 3
numbers = [1, 1, 2]return = [1, 1]
1 and 1 both have their double 2 present, and 2 is present in the list only once.
More Pure Storage interview questions
- One-Shot Callback Event DispatchONSITE INTERVIEW · Seen Dec 2026
- Perfect AND Tree Leaf UpdatesONSITE INTERVIEW · Seen Dec 2026
- Constant-Time Set OperationsPHONE SCREEN · Seen Sep 2026
- Rasterize a Circle with Integer PixelsONSITE INTERVIEW · Seen Sep 2026
- Racing ResultsOA · Seen Oct 2024
- Set Command SimulationONSITE INTERVIEW · Seen Aug 2024
- Count Different Palindrome SubstringsOA · Seen Jul 2024
- Count Palindromic SubstringsOA · Seen Jul 2024
- Find RepetitionsOA · Seen Nov 2023
- Bakery Quality ControlOA · Seen Nov 2023
Similar questions at other companies
- Build the Task HierarchyPendo · OA
- Macaron Order with Set DiscountsShopify · OAShopify interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Two SumAmazon · OA · PHONE SCREEN
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Customer Signer ScreeningState Farm · OA
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions