Shared Edge
Sometimes two lists are considered connected if they share either the same beginning or the same ending. Write a function common_end that takes two non-empty lists of numbers a and b. Return True if their first elements are equal or their last elements are equal. If both edges are different, return False.
Примеры
Ввод
[1, 2, 3], [7, 3]Вывод
TrueВвод
[1, 2, 3], [7, 3, 2]Вывод
FalseВвод
[1, 2, 3], [1, 3]Вывод
TrueНужно реализовать
def common_end(a: list[int], b: list[int]) -> bool:
Теги
listsarray
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
[1,2,3], [7,3]Expected
True2
Input
[1,2,3], [7,3,2]Expected
False3
Input
[1,2,3], [1,3]Expected
True4
Input
[2], [2]Expected
True5
Input
[1,2], [3,4]Expected
False6
Input
[0], [2]Expected
FalseFocus radio
Paused · SomaFM · Fluid