跳至主要內容

875. 爱吃香蕉的珂珂

T4mako算法链表双指针小于 1 分钟

875. 爱吃香蕉的珂珂

简单

题目描述open in new window

class Solution(object):
    def middleNode(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        left = head
        right = head
        i = 1
        while(right.next != None):
            if(i):
                left = left.next
                i -= 1
            else:
                i += 1
            right = right.next
        return left
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.5