摘要:
1 """ 2 Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文
摘要:
1 """ 2 You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their node 阅读全文
摘要:
1 """ 2 Reverse a singly linked list. 3 Example: 4 Input: 1->2->3->4->5->NULL 5 Output: 5->4->3->2->1->NULL 6 """ 7 8 """ 9 两种解法 10 解法一:迭代法 11 是先申请一个p 阅读全文
摘要:
1 """ 2 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. 3 To represent a cycle in the given linked lis 阅读全文
摘要:
1 """ 2 链表插入排序 3 """ 4 """ 5 难点在于设计链表,插入排序时如何找到插入位置,并恢复好下一个遍历结点的位置 6 所以需要两个while循环,第一个是整体遍历,第二个是找插入位置 7 """ 8 class ListNode: 9 def __init__(self, x): 阅读全文
摘要:
1 """ 2 Sort a linked list in O(n log n) time using constant space complexity. 3 Example 1: 4 Input: 4->2->1->3 5 Output: 1->2->3->4 6 Example 2: 7 In 阅读全文
摘要:
1 """ 2 Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separa 阅读全文
摘要:
1 """ 2 Given an unsorted array of integers, find the length of longest increasing subsequence. 3 Example 4 Input: [10,9,2,5,3,7,101,18] 5 Output: 4 6 阅读全文
摘要:
1 """ 2 We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is th 阅读全文
摘要:
1 """ 2 here are N network nodes, labelled 1 to N. 3 Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source 阅读全文