Ctrl K

Two Doubled Tickets

Easy
A concert issued tickets numbered 0 to n - 1, each number meant to appear exactly once. Yet n + 2 tickets were collected at the door: two numbers were forged, and each of them appears twice. You are given the list tickets of collected ticket numbers. Return the two numbers that appear twice, in any order.
Example 1
tickets=[2, 0, 3, 2, 1, 0] → [2, 0]

Here n = 4, so the numbers go from 0 to 3. Both 0 and 2 appear twice.

Example 2
tickets=[1, 1, 0, 0] → [1, 0]

n = 2, and both numbers are duplicated.

Constraints
  • 2 ≤ n ≤ 100
  • len(tickets) = n + 2
  • 0 ≤ tickets[i] < n
  • Every number from 0 to n - 1 appears, and exactly two of them appear twice
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Lost Ticket EasyEven Piles of Cards EasyPairs of Equal Values EasyRemainder-One Whiteboard EasyCoprime Digit Pairs Easy
loading Python…
Input
tickets=[2, 0, 3, 2, 1, 0]
Expected
[2, 0]

Run checks the first 3 tests in your browser. Submit checks all 51 tests on the server, hidden ones included.