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