Validate Unique User IDs

PYTHON coding challenge · Difficulty: easy · Topic: Data Validation Pipeline · +50 XP

Problem

An ingestion job must reject a batch whose user IDs are not unique. Write validate_unique_ids(user_ids) that returns True when every ID in the list appears exactly once, and False when any ID appears more than once. An empty list has no duplicates, so it is True.

Example Input

The data below is already defined — do not redefine it.

`python

user_ids = [101, 102, 103, 104, 105]

`

Expected Output

`

True

`

Notes

What this PYTHON challenge teaches you

“Validate Unique User IDs” is a easy-level PYTHON challenge focused on Data Validation Pipeline. Working through it gives you hands-on practice with hash set, uniqueness, data integrity — the kind of transformation you are asked to write in real data engineering work and in technical interviews. You can solve it directly in the browser: the dataset is pre-loaded, so you write the query or DataFrame code, run it, and compare your output against the expected result immediately.

Concepts covered

How to approach it

If you get stuck, work through these steps in order before looking at a full solution — each one narrows the problem down:

  1. Your result should return: a dictionary with:.
  2. Compare your output to the Expected Output — the columns and values must match. Row order is not graded; the rows themselves are, so return exactly this set and no extras.

Where this comes up

Variations of this problem have been reported in interviews at Google, Paytm, PhonePe. Interviewers use it to check whether you can express the logic cleanly and reason about correctness on edge cases such as ties, nulls and empty groups.

How to practise it on PySpark.in

Open the challenge, write your Python code in the editor and press Run to execute it against the sample dataset. Submitting checks your output against every test case, including hidden ones, so you find out straight away whether your logic holds up. You can retry as often as you like, and each solved challenge adds to your XP.

Related PYTHON challenges

Helpful resources

Frequently asked questions

Do I need to install Spark or a database to solve this?

No. The PYTHON environment runs in your browser with the sample data already loaded, so there is nothing to install or configure.

Is this challenge free?

Yes - the problem, the sample dataset, the hints and unlimited test runs are free.

What level is it?

It is rated easy and covers Data Validation Pipeline.

Solve this challenge free on PySpark.in