摘要: 1.非常量成员函数返回非常量 *this,常量成员函数返回常量 *this,指向常量对象。 2.重载函数必须参数数量或者类型不同吗? 答案是:否。还存在一种const重载; Person.h #pragma once #include <iostream> #include <string> #in 阅读全文
posted @ 2020-02-10 20:26 强威 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 1.修饰变量 const int i = 0; // i 为常量,不可修改 const int* p = &i; // 指向常量的指针 int* const p = &i; // 指针为常量,指向i不可修改 const int &r = i; // 常量引用,不可通过r修改i typedef int 阅读全文
posted @ 2020-02-10 17:56 强威 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 比较简单的一个题,但是浪费了很多时间,主要是因为刚开始的思路有一点漏洞。 Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Exa 阅读全文
posted @ 2020-02-09 22:16 强威 阅读(169) 评论(0) 推荐(0) 编辑
摘要: C++实现trid class TrieNode{ public: TrieNode():End(false), R(26){ links.resize(R); } void setEnd(){ End = true; } bool isEnd(){ return End; } bool conta 阅读全文
posted @ 2020-02-09 14:36 强威 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 单调队列分为递增队列和递减队列,一般用来求某个固定长度(例如:滑动窗口的最值)序列中的最大/最小值。 对于递增队列,队首元素就是最小值。 对于递减队列,队首元素就是最大值。 1.递增队列(队列首尾最小值) if(q.empty()) q.push_back(A[i]); else if(q.back 阅读全文
posted @ 2020-02-09 13:08 强威 阅读(300) 评论(0) 推荐(0) 编辑
摘要: Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' 阅读全文
posted @ 2020-02-08 17:45 强威 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1.归 ListNode* sortList(ListNode* head) { if (head == nullptr || head->next == nullptr) return head; // 1.将待排序序列分为两部分 ListNode* pre = nullptr, *slow = 阅读全文
posted @ 2020-02-07 22:36 强威 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4-> 阅读全文
posted @ 2020-02-07 22:17 强威 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 2020.2.6 494. Target Sum 我用的递归暴力解决的笨方法,本题有一种动态规划的好方法,但不能理解。待学习; 博客链接:https://www.cnblogs.com/qiang-wei/p/12271263.html 题目链接:https://leetcode.com/probl 阅读全文
posted @ 2020-02-06 23:19 强威 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = 阅读全文
posted @ 2020-02-06 23:18 强威 阅读(150) 评论(0) 推荐(0) 编辑