O10

Ticket Number Sequence Repair

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: NUMERIC

Problem Statement & Objective

Detect and fix out-of-order ticket numbers in an automated gate queue.

Function Signature (Python)

ticket_number_sequence_repair(numbers: list[int]) -> int

Input & Output Contract

Output Rule:Negatif olmayan tam sayı. Liste zaten kurallara uygunsa 0.

System Constraints

0 <= numaralar.length <= 10^5
-10^6 <= numaralar[i] <= 10^6

Example Execution Walkthrough

numaralar = [1, 1, 1]
sırala: [1, 1, 1]
1. numara: 1 -> maliyet 0, son = 1
2. numara: 1 -> en az 2 olmalı -> 1 -> 2, maliyet 1, son = 2
3. numara: 1 -> en az 3 olmalı -> 1 -> 3, maliyet 2, son = 3
toplam maliyet = 0 + 1 + 2 = 3

Example Test Scenarios (3)

Example 1
Input:[[1,1,1]]
Expected Output:3
Example 2: Zaten Artan Dizi
Input:[[1,2,3]]
Expected Output:0
Example 3: İki Eşit Sayı (2->3: +1)
Input:[[2,2]]
Expected Output:1
Loading Python Editor...
Input Parameters
[
  [
    1,
    1,
    1
  ]
]
Expected Output
3