Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Swap Nodes by tokiojapan55
from itertools import chain
def swap_nodes(a):
return list(chain(*[[b,a] for a,b in zip(a[::2], a[1::2])])) + (a[-1:] if len(a) % 2 else [])
June 2, 2020
Comments: