![](https://img-blog.csdnimg.cn/2020080616192064.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode
文章平均质量分 66
LeetCode 上的题目,不定时更新
知勉
山下旌旗在望,山头鼓角相闻。
展开
-
[LeetCode/力扣][Java] 0315. 计算右侧小于当前元素的个数(Count of Smaller Numbers After Self)
第二个问题就是树状数组的维护,在普通数组中,更新一个数值只需更改nums[i]的数值即可。但是在树状数组中,一个位置可能被多个区间包含,比如上图中的nums[2]对应四个区间tree[2],tree[4],tree[8],tree[16]。这个求最右侧的1及其后的0是通过lowbit函数实现的,具体原理涉及计租中的补码和反码,这里不详细展开了(我也不太明白)。数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元素的数量。输出:[2,1,1,0]原创 2022-11-22 22:09:45 · 252 阅读 · 1 评论 -
[LeetCode/力扣][Java] 0739. 每日温度(Daily Temperatures)
[LeetCode/力扣][Java] 0739. 每日温度(Daily Temperatures)原创 2022-11-14 20:56:47 · 724 阅读 · 0 评论 -
[LeetCode/力扣][Java] 0946. 验证栈序列(Validate Stack Sequences)
leetcode 946 验证栈序列:第一个想法是用数组flagarr模拟栈来记录当前push的数据,原创 2022-11-14 16:31:40 · 410 阅读 · 0 评论 -
[LeetCode/力扣][C++] 86. 分隔链表(Partition List)
给你一个链表的头节点 head 和一个特定值 x ,请你对链表进行分隔,使得所有 小于 x 的节点都出现在 大于或等于 x 的节点之前。相当于把整个列表视为两部分:大于等于x和小于x,利用四个分别指向两部分头和尾的指针来进行标记。输入:head = [1,4,3,2,5,2], x = 3。AC后还没看评论区大佬的代码和思路,但肯定比我厉害多了。你应当保留两个分区中每个节点的初始相对位置。输出:[1,2,2,4,3,5]遍历整个链表,若当前节点值。2 以及 链表节点值均。x时,输出头结点即可。原创 2022-11-09 19:53:18 · 375 阅读 · 0 评论 -
[c++]LeetCode#8. String to Integer (atoi)
Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this...原创 2020-04-17 17:56:25 · 139 阅读 · 0 评论 -
[C++]LeetCode#2 Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...原创 2020-04-10 16:58:30 · 85 阅读 · 0 评论 -
LeetCode 12. Integer to Roman
Roman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2020-04-04 10:35:21 · 80 阅读 · 0 评论