2018-11-16 22:45:48 一.单调队列 Monotone Queue 239. Sliding Window Maximum 问题描述: 问题求解: 本题是一个经典的可以使用双端队列或者说单调队列完成的题目,具体来说,就是通过双端队列将可能的最大值维护起来. public int[] maxSlidingWindow(int[] nums, int k) { if (nums == null || nums.length < k || k == 0) return new int[…
Description Little Bob is a famous builder. He bought land and wants to build a house. Unfortunately, the problem is the land's terrain, it has a variable elevation. The land is shaped like a rectangle, N meters wide and M meters long. It can be divi…
在前面几篇博文中曾经提到链表(list).队列(queue)和(stack),为了更加系统化,这里统一介绍着三种数据结构及相应实现. 1)链表 首先回想一下基本的数据类型,当需要存储多个相同类型的数据时,优先使用数组.数组可以通过下标直接访问(即随机访问),正是由于这个优点,数组无法动态添加或删除其中的元素,而链表弥补了这种缺陷.首先看一下C风格的单链表节点声明: // single list node define typedef struct __ListNode { int val; st…
Bob’s Race Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2833 Accepted Submission(s): 917 Problem Description Bob wants to hold a race to encourage people to do sports. He has got trouble i…