随笔分类 -  刷题

摘要:关于题目中遇到的一些坑1085 Perfect Sequence Link 这道题,别想着用 lower_bound 或 upper_bound 了。如果有相同元素,那么 len 很可能就算少了。 另外,p 要用 long long 类型,不然最后一个测试用例过不了。 不过这题用 lower_bound 或 upper_ 阅读全文
posted @ 2022-07-18 23:23 Ryomk 阅读(55) 评论(0) 推荐(0)
摘要:二叉树专题BST、AVL......前中后序遍历……什么?!不用建树 ||Φ|(|T|Д|T|)|Φ|| 阅读全文
posted @ 2022-07-15 12:23 Ryomk 阅读(52) 评论(0) 推荐(0)
摘要:1081 Rational Sum Link #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <string.h> #include <v 阅读全文
posted @ 2022-07-07 21:55 Ryomk 阅读(49) 评论(0) 推荐(0)
摘要:1095 Cars on Campus Link 配对要求是,如果一个车多次进入未出,取最后一个值;如果一个车多次out未进入,取第一个值。 注意:一个车可能出入校园好多次,停车的时间应该取之和 #include <iostream> #include <cstdio> #include <cstd 阅读全文
posted @ 2022-07-02 22:48 Ryomk 阅读(35) 评论(0) 推荐(0)
摘要:...占位 阅读全文
posted @ 2022-06-25 10:30 Ryomk 阅读(20) 评论(0) 推荐(0)
摘要:子序列专题最长递增子序列 LIS 用动态规划做。 Favorite Color Stripe (30) Link #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #i 阅读全文
posted @ 2022-06-25 10:28 Ryomk 阅读(34) 评论(0) 推荐(0)
摘要:滑动窗口专题Shopping in Mars (25) Link 这道题还可以用前缀和+二分做。 #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <s 阅读全文
posted @ 2022-06-25 09:40 Ryomk 阅读(47) 评论(0) 推荐(0)
摘要:Find More Coins (30) Link 01背包问题 #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <string.h> # 阅读全文
posted @ 2022-06-23 07:41 Ryomk 阅读(23) 评论(0) 推荐(0)
摘要:Sort with Swap(0,*) (25) Link 这道题要求一定是和0交换。 #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include < 阅读全文
posted @ 2022-06-22 14:15 Ryomk 阅读(37) 评论(0) 推荐(0)
摘要:Dijkstra专题Public Bike Management (30) Link 卡了半天原来是看漏了这句话:If there are more than one shortest path, the one that requires the least number of bikes sent from PBM 阅读全文
posted @ 2022-06-22 14:12 Ryomk 阅读(35) 评论(0) 推荐(0)
摘要:leetcode-1719 题目关键点: 树对 pairs[i]=[x_i,y_i],表示一个结点与其祖先,其中祖先可以是两者中的任意一个 别搞错了祖先的定义: 父亲(parent node):对于除根以外的每个结点,定义为从该结点到根路径上的第二个结点。 根结点没有父结点。 祖先(ancestor 阅读全文
posted @ 2022-06-15 09:36 Ryomk 阅读(47) 评论(0) 推荐(0)
摘要:Link class Solution { func findDiagonalOrder(_ mat: [[Int]]) -> [Int] { var ans: [Int] = [] let (m, n) = (mat.count, mat[0].count) let maxv = m + n - 阅读全文
posted @ 2022-06-14 18:45 Ryomk 阅读(26) 评论(0) 推荐(0)
摘要:PAT甲级刷题日记(三)摆烂人生 阅读全文
posted @ 2022-06-13 10:51 Ryomk 阅读(36) 评论(0) 推荐(0)
摘要:PAT甲级刷题日记(二)Would you like a cup of coffee? 阅读全文
posted @ 2022-06-12 20:22 Ryomk 阅读(30) 评论(0) 推荐(0)
摘要:PAT甲级刷题日记(一)很无聊的ԅ(¯﹃¯ԅ) 总结了一些零碎的知识点……代码倒是贴了不少。想要看题解的慎入。 阅读全文
posted @ 2022-06-08 09:32 Ryomk 阅读(45) 评论(0) 推荐(0)