LeetCode OJ Algorithm – Sliding Window Maximum(hard)

原题Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.For exampleGiven nums = [1,3,-1,-3,5,3,6,7], and k = 3.Window position Ma--------------- ----[1 3 -1] -3 5 3 6 7 1 [3 -1 -3]... Read More

LeetCode OJ Algorithm – reverse linked list ii (medium)

原题Reverse a linked list from position m to n. Do it in-place and in one-pass.For exampleGiven 1->2->3->4->5->NULL, m = 2 and n = 4return 1->4->3-&gNoteGiven m, n satisfy the following condition1 ≤ m ≤ n ≤ length of list.地址https://leetcode.com/problems/reverse-linked-list-ii程序范例[code lang="cpp"/** Definition for singly-linked list.* struct ListNode * int val;* ListNode *next;* ... Read More