摘要: 可以用 if ( a.find(x) == a.end() ) 判断 x 在 a 中是否存在 阅读全文
posted @ 2022-04-22 22:19 wKingYu 阅读(10) 评论(0) 推荐(0) 编辑
摘要: ![image](https://img2022.cnblogs.com/blog/2674359/202204/2674359-20220422220601594-1540187429.png) 阅读全文
posted @ 2022-04-22 22:06 wKingYu 阅读(11) 评论(0) 推荐(1) 编辑
摘要: 在出栈时需要进行两步操作,即先 top( ) 获得栈顶元素,再 pop( ) 删除栈顶元素 阅读全文
posted @ 2022-04-22 21:49 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要: ![image](https://img2022.cnblogs.com/blog/2674359/202204/2674359-20220422213958989-1883945665.png) 阅读全文
posted @ 2022-04-22 21:41 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 #include<iostream> #include<vector> using namespace std; int main() { // 初始化 a 为 1, 2, 3 vector<int> a({1, 2, 3}); // 也可以是 vector<int> a {1, 2, 阅读全文
posted @ 2022-04-22 19:26 wKingYu 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-22 17:28 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-21 23:38 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 迭代版本 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; * 阅读全文
posted @ 2022-04-21 23:23 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 class Solution { public: int strToInt(string str) { int k = 0; while (k < str.size() && str[k] == ' ') k++; long long res = 0; int minus = 1; i 阅读全文
posted @ 2022-04-21 23:11 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-21 22:56 wKingYu 阅读(14) 评论(0) 推荐(0) 编辑