摘要: 第一题 题目链接:https://leetcode.cn/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/ 个人题解: 用两个指针来移动。 \(i\) 和 \(j\) 分别表示奇数和偶数,从头遍历进 阅读全文
posted @ 2022-05-15 13:43 黑VS白-清墨 阅读(23) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode.cn/problems/largest-triangle-area/ 个人题解:暴力+叉积 代码: class Solution { public: int cross(int x1,int y1,int x2,int y2){ return x1*y2- 阅读全文
posted @ 2022-05-15 09:30 黑VS白-清墨 阅读(26) 评论(0) 推荐(0)
摘要: 只会写前两题,太菜了,第三题改bug改不出来,第四题属于看都没看了 第一题 题目链接:https://leetcode.cn/problems/find-the-k-beauty-of-a-number/ 个人题解: 首先把整数转化为字符串 遍历字符串,每次取出长度为 \(k\) 的子字符串 子字符 阅读全文
posted @ 2022-05-15 09:24 黑VS白-清墨 阅读(22) 评论(0) 推荐(0)
摘要: 第一题 题目链接:https://leetcode.cn/problems/he-bing-liang-ge-pai-xu-de-lian-biao-lcof/ 个人题解:创建一个虚拟头节点,遍历,如果碰到小的元素接上去即可。 代码: class Solution { public: ListNod 阅读全文
posted @ 2022-05-14 23:48 黑VS白-清墨 阅读(22) 评论(0) 推荐(0)
摘要: 第一题 题目链接:https://leetcode.cn/problems/shan-chu-lian-biao-de-jie-dian-lcof/ 个人题解:双指针遍历即可 代码: class Solution { public: ListNode* deleteNode(ListNode* he 阅读全文
posted @ 2022-05-13 20:52 黑VS白-清墨 阅读(21) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode.cn/problems/one-away-lcci/ 个人题解: 首先判断特殊情况,如果两个字符串的差值大于 \(1\) 则直接退出。 否则,双指针遍历,如果相等,则继续往前走,反之,只走一个,并增加答案。 比较答案是否是 \(0\) 或 \(1\) 即可 阅读全文
posted @ 2022-05-13 20:44 黑VS白-清墨 阅读(27) 评论(0) 推荐(0)
摘要: 第一题 题目链接:https://leetcode.cn/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/ 个人题解:动态规划 $f[i]=\left{\begin{matrix} f[i-1],stol(s[-1] \in [10,25])\ f[ 阅读全文
posted @ 2022-05-12 13:09 黑VS白-清墨 阅读(25) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode.cn/problems/delete-columns-to-make-sorted/ 个人题解:直接遍历即可,暴力两重循环 代码: class Solution { public: int minDeletionSize(vector<string>& s 阅读全文
posted @ 2022-05-12 08:28 黑VS白-清墨 阅读(26) 评论(0) 推荐(0)
摘要: 第一题 题目链接:https://leetcode.cn/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/ 个人题解:记录一个 \(maxsum\) 和一个 \(sum\),一个存答案,一个存每一次所找的最大值。 代码: class Solution { p 阅读全文
posted @ 2022-05-11 18:58 黑VS白-清墨 阅读(19) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode.cn/problems/serialize-and-deserialize-bst/ 个人题解:前序遍历+递归 代码: class Codec { public: // Encodes a tree to a single string. string s 阅读全文
posted @ 2022-05-11 18:54 黑VS白-清墨 阅读(36) 评论(0) 推荐(0)