Tool List: Two Smallest Values
Updated
Problem statement
Given a list of numeric tool values tools, return its two smallest entries, with the smaller value first.
For this exercise, treat each array position as a separate entry. Choose two different positions. Their values may be equal.
For this exercise, assume the task is only to select the two values; no circular movement, tool replacement, or combination operation is involved.
Function
twoSmallestTools(tools: int[]) → int[]Examples
Example 1
tools = [7,2,5,1]return = [1,2]The two smallest entries are 1 and 2.
Example 2
tools = [3,3,8]return = [3,3]Two separate entries may have the same minimum value.
Example 3
tools = [-4,6,-1,0]return = [-4,-1]Negative entries participate in the same numeric order.
Constraints
- For this exercise, assume
2 <= tools.length <= 10^5. - For this exercise, assume
-10^9 <= tools[i] <= 10^9.
More Vanguard Online Assessment questions
- Two SumOA · Seen Sep 2026
- Valid ParenthesesOA · Seen Sep 2026
- Are They PangramsOA · Seen Nov 2025
- Missing WordsOA · Seen Nov 2025
- Spam DetectionOA · Seen Nov 2025
- Binge WatchingOA · Seen Jan 2023
- Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
- Maximum Occurring CharacterOA · Seen Mar 2022
- Picking TicketsOA · Seen Mar 2022
- Group AnagramsOA · Seen Nov 2019
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Rank Football TeamsCapital One · OACapital One interview questions
- Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
- Rank Football TeamsPersona · OAPersona interview questions
- Meandering ArrayVerisk · OA
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
- Find Top Two TeamsAutodesk · OAAutodesk interview questions
- Total Server DowntimeVisa · OAVisa interview questions