The TransCompilator

Solved LeetCode program · 24 of 1,000

#0024 · Swap Nodes in Pairs

Medium Linked List chunk-01.md

Original English source

The values is a list of 1, 2, 3, and 4. The last is the last position of values.
For every position from 0 to last.
If position modulo 2 is 0 and position plus 1 is at most last, swap item position of values and item (position plus 1) of values.

For each value in values, show value.

Open in Playground Browse all 1,000 problems

Expected stdout

2
1
4
3