- 博客(8)
- 收藏
- 关注
原创 Error:default argument given for parameter 2 of……
错误代码:#include <iostream>using namespace std;class vehicle{protected: double speed; //速度,公里/小时 int wheels; //轮子数 double weight; //重量public: vehicle(double speed = 80, int wheels = 4, double weight = 1000); virtual void sh
2022-04-06 15:46:11
866
原创 leetcode 个人刷题反思总结 206. 反转链表(对递归的初步理解)
个人做题学习笔记方法一:迭代/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : va
2022-03-11 21:06:02
1136
原创 leetcode 个人刷题反思总结203. 移除链表元素
个人解法:迭代/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), n
2022-03-10 21:28:29
305
原创 leetcode 个人刷题反思总结 21. Merge Two Sorted Lists
个人解法:迭代双指针边比较边移动/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) :
2022-03-10 20:42:51
72
原创 leetcode 个人刷题反思总结 141. 环形链表
个人方法:快慢指针:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bool hasCycle(ListNode *head) { ListNode *p1=hea
2022-03-10 19:11:33
173
原创 时间问题待探索
时间问题此仅用时4msclass Solution {public: bool canConstruct(string ransomNote, string magazine) { int m[26]={0}; for(int i=0;i<magazine.length();i++) { m[magazine[i]-'a']++; } for(int i=0;i<ransomNo
2022-03-09 21:07:14
78
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人