上一页 1 2 3 4 5 6 7 ··· 17 下一页
摘要: class Solution { struct my_cmp{ bool operator()(const vector<int> &ite1, const vector<int> &ite2) { return ite1[0] < ite2[0]; // 升序 } } cmp; public: v 阅读全文
posted @ 2023-02-28 15:11 小超不挑食 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 移除指定元素 时间复杂度 O(n) 空间复杂度 O(1) class Solution { public: int removeElement(vector<int>& nums, int val) { int fast,low; for(fast = 0,low = 0; fast < nums. 阅读全文
posted @ 2023-02-27 14:39 小超不挑食 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 复杂度分析: 时间复杂度:O(n) 空间复杂度:O(1) /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nul 阅读全文
posted @ 2023-02-23 14:11 小超不挑食 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 20. 有效的括号 class Solution { private: stack<char> st; public: bool isValid(string s) { for (int i = 0; i < s.size(); i++) { switch(s[i]) { case '{': cas 阅读全文
posted @ 2023-02-22 20:50 小超不挑食 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 找出字符串中第一个匹配项的下标 class Solution { public: int strStr(string haystack, string needle) { if (needle.size() == 0) return 0; vector<int> next(needle.size() 阅读全文
posted @ 2023-02-21 20:45 小超不挑食 阅读(10) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 17 下一页