随笔分类 -  LeetCode

刷题记录
摘要:21 简单 Solution 模拟 Sample Code /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nu 阅读全文
posted @ 2021-09-17 16:09 ADRUI 阅读(47) 评论(0) 推荐(0)
摘要:11 中等 Solution 用i, j(i < j)表示选取的两条线位置, 则水量为$(j - i)* min(a_j, a_i)$ 我们考虑固定选取的右侧j, 则左侧可选为1...j - 1 设$i \in [1, j - 1]$, 若存在 \(k \in [1, j - 1] \ \& \ k 阅读全文
posted @ 2021-09-16 16:18 ADRUI 阅读(47) 评论(0) 推荐(0)
摘要:6 中等 Soluion 模拟规律题 找同一行相邻两个字符再原字符串中的间隔 Sample Code (map) class Solution { public: string convert(string s, int numRows) { if(numRows == 1) return s; s 阅读全文
posted @ 2021-09-15 10:03 ADRUI 阅读(48) 评论(0) 推荐(0)
摘要:1 简单 Soluion map 排序 + 双指针 Sample Code (map) class Solution { public: map<int, int> mp; map<int, int> pos; vector<int> twoSum(vector<int>& nums, int ta 阅读全文
posted @ 2021-09-14 17:01 ADRUI 阅读(43) 评论(0) 推荐(0)