摘要:
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
摘要:
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Brute Force算法,时间复杂度 O(mn 阅读全文
摘要:
Reverse a singly linked list.一般,reverse list, reverse list by pair 等都需要三个指针,cur = head, prev, 和当前的下一个temp. 这里在head到达边界之后,还会再走一步,所以对应新的表头的是prev. 1 class Solution(object): 2 def reverseList(self,... 阅读全文
摘要:
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 a 阅读全文