摘要: 1 /** 2 * struct ListNode { 3 * int val; 4 * struct ListNode *next; 5 * ListNode(int x) : val(x), next(nullptr) {} 6 * }; 7 */ 8 class Solution { 9 pu 阅读全文
posted @ 2022-02-17 19:38 技术笔记记录 阅读(261) 评论(0) 推荐(0)
摘要: 为啥这代码写的如此冗余 1 /* 2 struct RandomListNode { 3 int label; 4 struct RandomListNode *next, *random; 5 RandomListNode(int x) : 6 label(x), next(NULL), rand 阅读全文
posted @ 2022-02-15 21:46 技术笔记记录 阅读(41) 评论(0) 推荐(0)
摘要: getline分割字符串的原型说明: getline函数用于读取整行字符串。getline()的原型是istream& getline ( istream &is , string &str , char delim );参数解释:(1)istream &is 表示一个输入流,例如cin;(2)st 阅读全文
posted @ 2022-02-15 19:44 技术笔记记录 阅读(116) 评论(0) 推荐(0)
摘要: 之前自己的解答: 1 #include "iostream" 2 using namespace std; 3 int main() 4 { 5 int a,b; 6 int n=0; 7 int sum=0; 8 while(cin>>n) 9 { 10 11 sum+=n; 12 } 13 co 阅读全文
posted @ 2022-02-15 19:26 技术笔记记录 阅读(36) 评论(0) 推荐(0)
摘要: 考试过程中,遇到过这种情况,直接蒙了。 这是别人的代码 1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <vector> 5 #include <algorithm> 6 7 using namesp 阅读全文
posted @ 2022-02-14 22:44 技术笔记记录 阅读(760) 评论(0) 推荐(0)
摘要: 分析:我的想法是用cin加循环来屏蔽掉输入过程中的空格,于是写出了以下代码: 1 #include "iostream" 2 #include <vector> 3 #include "algorithm" 4 using namespace std; 5 int main() 6 { 7 8 st 阅读全文
posted @ 2022-02-14 22:28 技术笔记记录 阅读(89) 评论(0) 推荐(0)
摘要: 题目描述如下: 分析:之前做过这样的一道题,但是写得太繁琐,今天重新做了这道题。很明显的感觉做出来的效率提升了很多。 这道题的一个难点是,怎么样处理字符串长度大于8,截断后又大于8,又需要截断的情况。很显然,这种场景的处理逻辑应该要用到while循环。完整的代码如下: 1 #include <ios 阅读全文
posted @ 2022-02-14 21:25 技术笔记记录 阅读(132) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2022-02-12 22:54 技术笔记记录 阅读(38) 评论(0) 推荐(0)
摘要: 分析和思路:双指针,第一个指针先遍历k个节点,然后第二个指针从头结点开始遍历,当第1个指针遍历到尾结点时,第二个指针所在的节点就是倒数第k个节点,注意呀考虑k超出个数大小情况。 1 /** 2 * struct ListNode { 3 * int val; 4 * struct ListNode 阅读全文
posted @ 2022-02-12 09:48 技术笔记记录 阅读(49) 评论(0) 推荐(0)