Any duplicate transaction ids?

hashing

Any duplicate transaction ids?

Visa Python Interview Question

Visa's data quality checks flag a batch of transactions if the same transaction id appears more than once.

Write a function has_duplicates(transaction_ids) that returns True if any id appears at least twice, and False if every id is unique.

Asked of

  • Data Analyst
  • Data Engineer
  • Data Scientist
  • ML Engineer
  • AI Engineer

Example 1

Input

transaction_ids = [101, 205, 101, 330]

Output

True

Example 2

Input

transaction_ids = [1, 2, 3, 4]

Output

False

Explanation

In the first example, id 101 appears twice, so the batch is flagged. In the second example, all four ids are different.

Submit also runs 4 hidden test cases that check edge cases.