![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 61
Yjnull
丹青之妙,花敛客,日藏光,月遮羞,墨分五彩,化在渐染之间!
展开
-
LeetCode 371.Sum of Two Integers 位运算实现加法(减法)
1.原题Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.(计算两个数的和,但是不能用+和-操作符)Example: Given a = 1 and b = 2, return 3.2.思路不允许用+、-操作符,那么暂且只能想到位运算来入...原创 2016-12-13 16:09:15 · 319 阅读 · 1 评论 -
LeetCode 23. Merge k Sorted Lists
23. Merge k Sorted Lists原题: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. (合并 k 个已排序的linked list 并作为一个 list 返回,分析和描述它的复杂度。)解法: 由于之前做过合并2个已排序 li...原创 2018-03-18 23:24:43 · 99 阅读 · 0 评论 -
LeetCode 34. Search for a Range
34. Search for a Range原题: Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in th...原创 2018-04-26 22:47:34 · 125 阅读 · 0 评论 -
双端队列题解
双端队列题解1. 生成窗口最大值数组牛客链接LeetCode 链接方法一:暴力法该题最直接的解法,直接遍历每个滑动窗口,找到每个窗口的最大值即可。一共会有 N - k + 1 个滑动窗口,每个滑动窗口有 k 个元素,所以时间复杂度为 O(Nk),表现较差。方法二:双端队列这里采用 以双向链表实现的 LinkedList 作为双端队列。算法遍历整个数组。把当前元素的索引添加到双...原创 2019-09-25 10:55:38 · 304 阅读 · 0 评论 -
单调栈题解
单调栈题解1. 单调栈结构牛客链接方法:单调栈算法这里维护一个单调递增栈,可以找到比当前元素要小的元约定:当前元素 cur,栈顶元素 top,出栈的栈顶元素 tempTop遍历数组如果当前元素大于栈顶元素,则入栈(入栈元素索引,而不是值)否则,将栈顶元素出栈,此时,离 tempTop 左边最近且值比 tempTop 小的就是当前的栈顶元素 top,离 tempTop 右边最近且...原创 2019-09-25 13:35:56 · 250 阅读 · 0 评论