Leetcode - 24. Swap Nodes in Pairs
문제
정답
class Solution:
def swapPairs(self, head: Optional[ListNode]) -> Optional[ListNode]:
dummy = head
while head and head.next:
adj = head.next
head.val, adj.val = adj.val, head.val
head = head.next.next
return dummy