摘要:
题目链接:https://leetcode-cn.com/problems/permutations-ii/ 题目描述: 题解: class Solution { public: vector<vector<int>> result; vector<int> path; void backTrack 阅读全文
摘要:
题目链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 题目描述: 题解: class Solution { public: int lengthOfLongestSubstring( 阅读全文
摘要:
题目链接:串联字符串的最大长度 题目描述: 题解: class Solution { public: int maxLen = 0; void backTracking(vector<string>& arr, int index, vector<int>& letters) { int len = 阅读全文
摘要:
题目链接:https://leetcode-cn.com/problems/reverse-words-in-a-string/ 题目描述: 题解: class Solution { public: string reverseWords(string s) { stack <string> stk 阅读全文
摘要:
题目链接: https://leetcode-cn.com/problems/lemonade-change/ 题目描述: 题解: class Solution { public: bool lemonadeChange(vector<int>& bills) { unordered_map<int 阅读全文
摘要:
题目链接: https://leetcode-cn.com/problems/reverse-string-ii/ 题目描述: 题解: 要点:遍历的步长为2 * k。当需要固定规律一段一段去处理字符串的时候,要想想在在for循环的表达式上做做文章。 class Solution { public: 阅读全文
摘要:
题目链接:https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/ 题目描述: 题解: 空间复杂度:O(1) 1.先找出字符串中含有多少个空格 2.对原字符串空间扩容 3.定义两个指针,一个指向新字符串的末尾,一个指向原始字符串的末尾 class 阅读全文
摘要:
题目链接:https://leetcode-cn.com/problems/candy/ 题目描述: 题解: class Solution { public: int candy(vector<int>& ratings) { vector<int> candyVec(ratings.size(), 阅读全文
摘要:
题目链接:https://leetcode-cn.com/problems/palindrome-linked-list/ 题目描述: 题解: /** * Definition for singly-linked list. * struct ListNode { * int val; * List 阅读全文
摘要:
题目链接:https://leetcode-cn.com/problems/gas-station/ 题目描述: 题解: 1.如果gas的总和小于cost总和,一定不能跑一整圈。 2.每个加油站剩余量rest[i] = gas[i] - cost[i] 3.i从0开始累加rest[i],和记为cur 阅读全文