Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Common Tail by freeman_lex
def lists_intersect(l1: list[int], l2: list[int]) -> int | None:
i = -1
try:
while l1[i] == l2[i]:
i -= 1
except IndexError:
pass
return l1[i + 1] if i != -1 else None
print("Example:")
print(lists_intersect([1, 2, 3, 4], [5, 6, 3, 4]))
assert lists_intersect([], [1, 2, 3]) == None
assert lists_intersect([1], [1]) == 1
assert lists_intersect([3], [1, 2, 3]) == 3
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 9, 2022