加载中...

上一页 1 ··· 13 14 15 16 17
摘要: 比map o (logn)查的更快的hash——map o(1),但不一定,且增加一点内存, 但c++没有提供给这个模板, ##关于基本语法 map.insert( , ); map.count(key)//找map是否存过这个东西,有的话返回1,没有返回0,因为map只有一个 map.find(k 阅读全文
posted @ 2021-11-29 21:52 liang302 阅读(37) 评论(0) 推荐(0) 编辑
摘要: ##反转链表 public: ListNode* reverseList(ListNode* head) { // 1. 递归终止条件 if (head == nullptr || head->next == nullptr) return head;//最后一个是p //注意上面的顺序不能调换!否 阅读全文
posted @ 2021-11-28 13:20 liang302 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 这个直接能代表数组里面的元素 for (int x: nums); ###作用就是迭代容器中所有的元素,每一个元素的临时名字就是x,等同于下边代码,但需要加*号 for (vector<int>::iterator iter = nums.begin(); iter != nums.end(); i 阅读全文
posted @ 2021-11-28 11:11 liang302 阅读(30) 评论(0) 推荐(0) 编辑
摘要: #首先理解 比如一个链表是这样的:let aaa = [1, 2, 3, 4] 那么 aaa.val 1 aaa.next [2, 3, 4]; aaa.next.val 2 ##将vector里的元素一次遍历放到里,构建链表 //当容器存的是结点的时候 vector<ListNode*>a; Li 阅读全文
posted @ 2021-11-28 10:52 liang302 阅读(63) 评论(0) 推荐(0) 编辑
摘要: ##将vector元素放到set中 class Solution { public: bool containsDuplicate(vector<int>& nums) { unordered_set<int> s(nums.begin(), nums.end()); return s.size() 阅读全文
posted @ 2021-11-28 10:51 liang302 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 新建立 用于记日记和记笔记 阅读全文
posted @ 2021-11-27 11:56 liang302 阅读(21) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17