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
PostgreSQLv16

Čia bus kodo vykdymo rezultatas

Visible tests
1
Input
[1,2,3], [7,3]
ExpectedTrue
2
Input
[1,2,3], [7,3,2]
ExpectedFalse
3
Input
[1,2,3], [1,3]
ExpectedTrue
4
Input
[2], [2]
ExpectedTrue
5
Input
[1,2], [3,4]
ExpectedFalse
6
Input
[0], [2]
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid