Values Only on One Side
Imagine comparing two lists to see which numbers appear only in one of them. Write a function find_difference that receives two integer lists a and b. Return a list of two lists: first the unique numbers that are in a but not in b, then the unique numbers that are in b but not in a. Sort the numbers inside each result list in ascending order.
Примеры
Ввод
[1, 2, 3], [2, 4, 6]Вывод
[[1, 3], [4, 6]]Ввод
[1, 2, 3, 3], [1, 1, 2, 2]Вывод
[[3], []]Ввод
[], [1, 2]Вывод
[[], [1, 2]]Нужно реализовать
def find_difference(a: list[int], b: list[int]) -> list[list[int]]:
Теги
arraysethashmap
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
[1,2,3], [2,4,6]Expected
[[1,3],[4,6]]2
Input
[1,2,3,3], [1,1,2,2]Expected
[[3],[]]3
Input
[], [1,2]Expected
[[],[1,2]]4
Input
[5], [5]Expected
[[],[]]5
Input
[1,2,3], [1,2,3]Expected
[[],[]]6
Input
[10,9,8], [8,7]Expected
[[9,10],[7]]Focus radio
Paused · SomaFM · Fluid