O10
Ticket Number Sequence Repair
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]) -> intInput & 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^6Example 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 = 3Example Test Scenarios (3)
Example 1
Input:
[[1,1,1]]Expected Output:
3Example 2: Zaten Artan Dizi
Input:
[[1,2,3]]Expected Output:
0Example 3: İki Eşit Sayı (2->3: +1)
Input:
[[2,2]]Expected Output:
1