题目描述:import Foundation class For17Solution { func mergeListNode(_ head1: ListNode?,_ head2: ListNode?) -> ListNode? { if head1 == nil { return head2 } if head2 == nil { return head1 } var newHead : ...
题目描述:链表中倒数第 K 个结点。import Foundation class For15Solution { func reversedK(_ head: ListNode?,_ k: Int) -> ListNode? { guard head != nil && k != 0 else { return nil } var i = 0 var p = head var q = head ...
题目描述:1->2->3->4,4->3->2->1import Foundation class For16Solution { func reversedListNode(_ head: ListNode?) -> ListNode? { if head == nil || head?.next == nil { return head } var pre : ListNode? var cur = head p...
题目描述:调整数组顺序使奇数位于偶数前面。import Foundation class For14Solution { func ReorderOddEven(_ n: [Int]) -> [Int] { var s = n var left = 0 var right = n.count - 1 while left < right { while left < right && s[left...