Shared Unique Values
Given two lists of integers a and b, find the values that appear in both lists. Each shared value should appear only once in the answer, even if it appears multiple times in the input. Sort the result in ascending order and return it.
Примеры
Ввод
[1, 2, 2, 3], [2, 3, 4]Вывод
[2, 3]Ввод
[1, 2], [3, 4]Вывод
[]Ввод
[5, 5, 5], [5]Вывод
[5]Нужно реализовать
def intersection(a: list[int], b: list[int]) -> list[int]:
Теги
listshashmap
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
[1,2,2,3], [2,3,4]Expected
[2,3]2
Input
[1,2], [3,4]Expected
[]3
Input
[5,5,5], [5]Expected
[5]4
Input
[], [2,3,4]Expected
[]5
Input
[0,0,0,0], []Expected
[]6
Input
[5,5,5], [5,5]Expected
[5]Focus radio
Paused · SomaFM · Fluid