URL
Swap Nodes in Pairs - LeetCode
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/problems/0024/main.fsx
type LinkedList =
| Empty
| ListNode of int * LinkedList
let rec swapPair (node: LinkedList) : LinkedList =
match node with
| Empty -> Empty
| ListNode (x, next) ->
match next with
| Empty -> node
| ListNode (y, nnext) -> ListNode(y, ListNode(x, (swapPair nnext)))
I think this problem is not suit for F#