Duplicate and Missing

Imagine a list that should contain every number from 1 to n, but something went wrong while filling it. One number was written twice, and another number was lost because of that. Write a function find_error_nums that finds both values. Return them as a list in this order: first the duplicated number, then the missing number.

Примеры

Ввод
[1, 2, 2, 4]
Вывод
[2, 3]
Ввод
[1, 1]
Вывод
[1, 2]
Ввод
[3, 2, 3, 4, 6, 5]
Вывод
[3, 1]

Нужно реализовать

def find_error_nums(nums: list[int]) -> list[int]:

Теги

arrayhashmapmath
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
[1,2,2,4]
Expected[2,3]
2
Input
[1,1]
Expected[1,2]
3
Input
[3,2,3,4,6,5]
Expected[3,1]
4
Input
[2,2]
Expected[2,1]
5
Input
[1,5,3,2,2,7,6,4,8,9]
Expected[2,10]
6
Input
[1,2,4,4,5]
Expected[4,3]
Focus radio
Paused · SomaFM · Fluid