FastPrepPrint Unique Numbers

Print Unique Numbers

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN
Learn

Problem statement

Return each distinct integer from nums exactly once, preserving the order of its first appearance.

Function

uniqueNumbers(nums: int[]) → int[]

Examples

Example 1

nums = [4,1,4,7,1,9]return = [4,1,7,9]

Later copies of 4 and 1 are skipped.

Constraints

  • 0 <= nums.length <= 2 * 10^5.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int[] uniqueNumbers(int[] nums) {
  // Write your code here.
}
nums[4,1,4,7,1,9]
expected[4,1,7,9]
Checking account…