You are given a non-negative integer n. Your task is to return the number formed by keeping only the first occurrence of each digit, while preserving the original order of the digits.
Any digit that appears again after its first occurrence must be removed. The remaining digits must stay in the same relative order as in the original number.
Input: n = 1122334
Output: 1234
Explanation: Only the first occurrence of each digit is kept, producing 1234.
Input: n = 122333
Output: 123
Explanation: Repeated occurrences of 2 and 3 are removed, leaving their first appearances in the original order.
Input: n = 1234
Output: 1234
Explanation: Every digit is distinct, so no digits need to be removed.
Sign in to write, run, and submit your solution against the full test suite.