摘要: 有关C++字符串截取substr的用法 一、string s = "abcd"; string s1 = s.substr(2); // s1 = "cd" 表示截取从下标2开始到字符串末尾 二、string s = "abcd" string s1 = s.substr(1,2); //s1 = 阅读全文
posted @ 2021-01-31 20:32 Uitachi 阅读(171) 评论(0) 推荐(0)
摘要: 题目 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。返回 s 所有可能的分割方案。 代码 1 class Solution { 2 public: 3 vector<vector<string>>res; 4 vector<string>path; 5 bool check(st 阅读全文
posted @ 2021-01-31 20:27 Uitachi 阅读(69) 评论(0) 推荐(0)
摘要: 题目 分析(按照y总思路) 首先先将题目进行转化,因为题目要求:在吃完 所有 第 i - 1 类糖果之前,不能 吃任何一颗第 i 类糖果。所以我们把已有的糖果种类糖果数看成一个线性数轴,如下: 只有数轴左边糖果吃完,才可以吃右边的糖果。接下来把能不能在给定的天数吃到某类的糖果这一问题转换为能不能在给 阅读全文
posted @ 2021-01-31 17:53 Uitachi 阅读(164) 评论(0) 推荐(0)
摘要: 题目 https://leetcode-cn.com/problems/maximum-number-of-balls-in-a-box/ 代码 1 class Solution { 2 public: 3 int countBalls(int l, int h) { 4 vector<int>su 阅读全文
posted @ 2021-01-31 15:14 Uitachi 阅读(94) 评论(0) 推荐(0)