Validate Unique User IDs
PYTHON coding challenge · Difficulty: easy · +50 XP
Function Signature
------------------
def validate_ids(user_ids: list) -> dict:
Problem
-------
Given a list of user IDs, validate them
and return a report.
Return a dictionary with:
"valid" → list of valid IDs
"duplicates" → list of IDs appearing 2+
"invalid" → list of IDs that are not
positive integers
Rules:
• Valid: positive integer (>0), unique
• Duplicate: appears more than once
• Invalid: negative, zero, non-integer,
or non-numeric string
Example 1
---------
Input:
[101, 102, 101, -5, "abc", 103, 0]
Output:
{
"valid": [102, 103],
"duplicates": [101],
"invalid": [-5, "abc", 0]
}
Example 2
---------
Input: [1, 2, 3, 4, 5]
Output:
{
"valid": [1, 2, 3, 4, 5],
"duplicates": [],
"invalid": []
}
Example 3 (Edge case)
---------------------
Input: []
Output: {"valid":[], "duplicates":[],"invalid":[]}
Constraints
-----------
• 0 <= len(user_ids) <= 100,000
• Each element can be any Python type
• Return lists sorted in ascending order