上一页 1 2 3 4 5 6 7 ··· 13 下一页
摘要: problem:https://leetcode.com/problems/next-greater-node-in-linked-list/ 维护递减的单调栈。这道题对象是链表,不像数组可以快速通过下标索引,所以比较方便的做法是在栈中同时记录数字和对应的下标,并且默认填0,如果找到了比它大的第一个 阅读全文
posted @ 2019-08-11 16:05 fish1996 阅读(116) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/largest-rectangle-in-histogram 经典单调栈题目。维护递增的单调栈,当发现当前数字比栈顶要小的时候,此时栈顶元素是最大的(大于栈里的下一个元素,也大于当前元素),所以可以计算以当前栈顶元素为高的矩 阅读全文
posted @ 2019-08-11 15:12 fish1996 阅读(89) 评论(0) 推荐(0)
摘要: 这一次终于没有提交WA了。 1154. Day of the Year 简单题。打印一年到现在的天数,区分闰年即可。// 不要问我run, ping是啥意思 = =。 1155. Number of Dice Rolls With Target Sum 中等题,动态规划。给你d个骰子,包含数字为1~ 阅读全文
posted @ 2019-08-11 13:46 fish1996 阅读(211) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/find-the-duplicate-number/ 查找是否存在环。快指针走2步,慢指针走1步,相遇则存在环。设慢指针走了路程s,则快指针走了2s,环长度为s。若环的起始位置为d,则慢指针的位置在起始位置过一点的地方,它只 阅读全文
posted @ 2019-08-11 02:48 fish1996 阅读(198) 评论(0) 推荐(0)
摘要: problem: https://leetcode.com/problems/search-in-rotated-sorted-array/ 二分搜索题。检查二分后的半段是否满足递增条件,如果满足且数据落在这一区间,就在这一区间查找,否则到另一区间查找。 阅读全文
posted @ 2019-08-11 02:07 fish1996 阅读(124) 评论(0) 推荐(0)
摘要: 最后一题比赛快结束的时候想到怎么做了(通过WA的数据猜出来的),比赛后10分钟做出来的。最终做了3题,时间1个小时左右吧。 1150. Check If a Number Is Majority Element in a Sorted Array 这道题理论应该用二分,但是数据量很小(1000),所 阅读全文
posted @ 2019-08-11 00:29 fish1996 阅读(278) 评论(0) 推荐(0)
摘要: problem: https://leetcode.com/problems/search-a-2d-matrix/ 经典二分搜索。本质上还是一维数组。 阅读全文
posted @ 2019-08-10 22:04 fish1996 阅读(129) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/count-numbers-with-unique-digits/ 1 : 10 2: 10 + 9 x 9 3: 10 + 9 x 9 + 9 x 9 x 8 4: 10 + 9 x 9 + 9 x 9 x 8 x 7 … 阅读全文
posted @ 2019-08-10 19:12 fish1996 阅读(153) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/russian-doll-envelopes/ 最长连续子序列类型问题。先排序,dp[i]记录使用第i个套娃的最大数量。 阅读全文
posted @ 2019-08-10 18:19 fish1996 阅读(204) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/integer-break/ 枚举所有整数相加,取它们最大乘积的乘积,然后选择最大值。 阅读全文
posted @ 2019-08-10 18:06 fish1996 阅读(123) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 13 下一页