Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
zip, reversed solution in Clear category for Common Tail by Sim0000
def common_tail(a: list[int], b: list[int]) -> int | None:
c = None
for ca, cb in zip(reversed(a), reversed(b)):
if ca != cb: break
c = ca
return c
print("Example:")
print(common_tail([1, 2, 3, 4], [5, 6, 3, 4]))
assert common_tail([], [1, 2, 3]) == None
assert common_tail([1], [1]) == 1
assert common_tail([3], [1, 2, 3]) == 3
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 8, 2022
Comments: