024,Swap Nodes in Pairs
https://leetcode.com/problems/swap-nodes-in-pairs/description/
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.
public class Solution {
public ListNode swapPairs(ListNode head) {
if ((head == null)||(head.next == null))
return head;
ListNode n = head.next;
head.next = swapPairs(head.next.next);
n.next = head;
return n;
}
}
相關文章
- Swap Nodes in PairsAI
- 24. Swap Nodes in PairsAI
- Leetcode Swap Nodes in PairsLeetCodeAI
- Leetcode 24 Swap Nodes in PairsLeetCodeAI
- LeetCode 24 Swap Nodes in PairsLeetCodeAI
- Leetcode-Swap Nodes in PairsLeetCodeAI
- Swap Nodes in Pairs leetcode javaAILeetCodeJava
- Leetcode 線性表 Swap Nodes in PairsLeetCodeAI
- [LeetCode] Swap Nodes in Pairs 成對交換節點LeetCodeAI
- 兩種解法搞定Swap Nodes in Pairs演算法題AI演算法
- 【LeetCode】Swap Nodes in Pairs 連結串列指標的應用LeetCodeAI指標
- 【leetcode】24. Swap Nodes in Pairs 連結串列奇偶節點交換LeetCodeAI
- Palindrome PairsAI
- 11.2.0.1 rac 2nodes asm aix6.1 orarootagent.bin swap memory記憶體洩漏ASMAI記憶體
- 11.2.0.1 rac 2nodes asm aix6.1 orarootagent.bin swap memory記憶體洩漏ASMAI記憶體
- L2-024 部落
- 13-Architecture-nodes
- L1-024 後天
- 軟體工程日報024軟體工程
- 【Lintcode】572. Music PairsAI
- 1512. Number of Good PairsGoAI
- LeetCode-Palindrome PairsLeetCodeAI
- 532. K-diff Pairs in an ArrayAI
- HINT no_swap_join_inputs/swap_join_inputs
- Vim auto-pairs設定選項AI
- 【LeetCode】Palindrome Pairs(336)LeetCodeAI
- [MySQL光速入門]024 聊聊函式MySql函式
- 024 Rust死靈書之Send和SyncRust
- [LeetCode] 336. Palindrome PairsLeetCodeAI
- Diff-prime Pairs(思維+素數篩)AI
- LeetCode677. Map Sum PairsLeetCodeAI
- LeetCode-Find K Pairs with Smallest SumsLeetCodeAI
- 【024期】JavaWeb面試題(五):Filter和ListenerJavaWeb面試題Filter
- web專案024-----賬戶登陸Web
- IPP SWAP孵化器|IPP SWAP系統開發分析
- Leetcode Reverse Nodes in k-GroupLeetCode
- One cause leads to the error(The specified nodes are not clusterable)Error
- OCR integrity results are inconsistent amongst the nodes.