
leetcode队列
文章平均质量分 77
Bryan要加油
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal (Leetcode每日一题-2021.02.21)
Problem Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit. Constraints: 1 <= nums.length &l原创 2021-02-21 20:41:20 · 238 阅读 · 0 评论 -
面试题 03.04. Implement Queue using Stacks LCCI
Problem Implement a MyQueue class which implements a queue using two stacks. Notes: You must use only standard operations of a stack – which means only push to top, peek/pop from top, size, and is em...原创 2020-03-23 23:15:53 · 234 阅读 · 0 评论 -
225. Implement Stack using Queues(Leetcode每日一题-2020.03.01)
Problem Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. empty() – Return...原创 2020-03-08 11:33:39 · 195 阅读 · 0 评论 -
513. Find Bottom Left Tree Value
Problem Given a binary tree, find the leftmost value in the last row of the tree. Note: You may assume the tree (i.e., the given root node) is not NULL. Example1 Example2 Solution 二叉树层序遍历的变种题。 /** ...原创 2020-03-08 10:33:31 · 123 阅读 · 0 评论 -
面试题59 - II. 队列的最大值(Leetcode每日一题-2020.03.07)
Problem 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都是O(1)。 若队列为空,pop_front 和 max_value 需要返回 -1 Example1 输入: [“MaxQueue”,“push_back”,“push_back”,“max_value”,“pop_fron...原创 2020-03-07 22:02:36 · 255 阅读 · 0 评论 -
994. Rotting Oranges(Leetcode每日一题-2020.03.04)
Problem In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minu...原创 2020-03-04 19:52:26 · 318 阅读 · 0 评论 -
面试题32 - III. 从上到下打印二叉树 III
Problem 请实现一个函数按照之字形顺序打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右到左的顺序打印,第三行再按照从左到右的顺序打印,其他行以此类推。 Example 给定二叉树: [3,9,20,null,null,15,7], 返回其按之字形顺序层次遍历结果: Solution/** Definition for a binary tree node. struct...原创 2020-03-03 23:14:39 · 282 阅读 · 0 评论 -
面试题32 - I. 从上到下打印二叉树
Problem 从上到下打印出二叉树的每个节点,同一层的节点按照从左到右的顺序打印。 Example 给定二叉树: [3,9,20,null,null,15,7], 返回:[3,9,20,15,7] Solution /** Definition for a binary tree node. struct TreeNode { int val; TreeNode *left;...原创 2020-03-03 20:31:13 · 237 阅读 · 0 评论 -
637. Average of Levels in Binary Tree
Problem Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example Solution 考察二叉树的层序遍历。 借助队列完成。levelLast用于标记当前层的最后一个树节点。 从队列中取出的节点与levelLast相同...原创 2020-02-18 23:04:52 · 234 阅读 · 0 评论