当前位置: 首页 > news >正文

合肥做个网站什么价格官方网站页面尺寸

合肥做个网站什么价格,官方网站页面尺寸,网站开发工作介绍,pc网站建设哪个好39.组合总和给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。candidates 中的 同一个 数字可以 无限制重复被…

39.组合总和

给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。

candidates 中的 同一个 数字可以 无限制重复被选取 。如果至少一个数字的被选数量不同,则两种组合是不同的。 

对于给定的输入,保证和为 target 的不同组合数少于 150 个。

示例 1:

输入:candidates = [2,3,6,7], target = 7
输出:[[2,2,3],[7]]
解释:
2 和 3 可以形成一组候选,2 + 2 + 3 = 7 。注意 2 可以使用多次。
7 也是一个候选, 7 = 7 。
仅有这两种组合。

示例 2:

输入: candidates = [2,3,5], target = 8
输出: [[2,2,2,2],[2,3,3],[3,5]]

示例 3:

输入: candidates = [2], target = 1
输出: []

提示:

  • 1 <= candidates.length <= 30
  • 2 <= candidates[i] <= 40
  • candidates 的所有元素 互不相同
  • 1 <= target <= 40
class Solution {
private:vector<vector<int>> result;vector<int> path;void backtracking(vector<int> candidates, int target, int sum, int startIndex) {if(sum > target) {return;}if(sum == target) {result.push_back(path);return;}for(int i = startIndex; i < candidates.size(); i++) {sum += candidates[i];path.push_back(candidates[i]);backtracking(candidates, target, sum, i);sum -= candidates[i];path.pop_back();}}public:vector<vector<int>> combinationSum(vector<int>& candidates, int target) {result.clear();path.clear();backtracking(candidates, target, 0, 0);return result;}
};

40.组合总和II

给定一个候选人编号的集合 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。

candidates 中的每个数字在每个组合中只能使用 一次 。

注意:解集不能包含重复的组合。 

示例 1:

输入: candidates = [10,1,2,7,6,1,5], target = 8,
输出:
[
[1,1,6],
[1,2,5],
[1,7],
[2,6]
]

示例 2:

输入: candidates = [2,5,2,1,2], target = 5,
输出:
[
[1,2,2],
[5]
]

提示:

  • 1 <= candidates.length <= 100
  • 1 <= candidates[i] <= 50
  • 1 <= target <= 30
class Solution {
private:vector<vector<int>> result;vector<int> path;void backtracking(vector<int>& candidates, int target, int sum, int startIndex, vector<bool>& used) {if(sum > target) {return;}if(sum == target) {result.push_back(path);return;}for(int i = startIndex; i< candidates.size(); i++) {if(i > 0 && candidates[i] == candidates[i-1] && used[i-1] == false){continue;}sum += candidates[i];path.push_back(candidates[i]);used[i] = true;backtracking(candidates, target, sum, i + 1, used);  used[i] = false;sum -= candidates[i];path.pop_back();}}public:vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {vector<bool> used(candidates.size(), false);path.clear();result.clear();sort(candidates.begin(), candidates.end());backtracking(candidates, target, 0, 0, used);return result;}
};

131.分割回文串

给你一个字符串 s,请你将 s 分割成一些 子串,使每个子串都是 回文串 。返回 s 所有可能的分割方案。

示例 1:

输入:s = "aab"
输出:[["a","a","b"],["aa","b"]]

示例 2:

输入:s = "a"
输出:[["a"]]

提示:

  • 1 <= s.length <= 16
  • s 仅由小写英文字母组成
class Solution {
private:vector<vector<string>> result;vector<string> path;bool isPalindrome(const string&s, int start, int end) {for(int i = start, j = end; i < j; i++, j--) {if(s[i] != s[j]) {return false;}}return true;}void backtracking(const string& s, int startIndex) {if(startIndex >= s.size()) {result.push_back(path);return ;} for(int i = startIndex; i < s.size(); i++) {if(isPalindrome(s, startIndex, i)) {string str = s.substr(startIndex, i - startIndex + 1);path.push_back(str);} else {continue;}backtracking(s, i+1);path.pop_back();}}public:vector<vector<string>> partition(string s) {result.clear();path.clear();backtracking(s, 0);return result;       }
};

http://www.dtcms.com/a/444356.html

相关文章:

  • 爱途 中山网站制作宁波标志设计公司
  • 第4讲:分支和循环(下)——猜数字游戏实战
  • 数据网站火车头 wordpress 4.8
  • 教做面包的网站做网站电销
  • 中文网站建设中模板关键词做网站标题是什么意思
  • 企业网站源码哪个好徐州手工活外发加工网
  • 网站开发问题广告设计模板素材图片
  • 变装小说第三性wordpress谷歌seo需要做什么的
  • 新华美玉官方网站在线做wordpress主题外贸
  • 免费网站注册免费创建网站商标设计软件生成器
  • 网站seo快排软件怎么做网站优化 sit
  • 常州外贸集团 网站建设ghost系统怎么卸载wordpress
  • 一个服务器可以做多个网站吗php会了 怎么做网站
  • 网页设计与网站建设专业做网站有哪个软件好
  • 莆田企业网站建设it外包 源码
  • 企业公司做网站wordpress 随机页面
  • 官方查企业信息的网站荆州企业网站建设
  • 网站开发与建设方向济宁市城市建设投资中心网站
  • 快速做网站团队电子商务网站建设方案设计报告
  • 赣州营销型网站策划网页编辑模式快捷键
  • 网站响应是什么问题吗南昌住房城市建设支行官方网站
  • 网站不允许上传文件大连在哪里哪个省
  • 成都网站建设快速服务wordpress博客没有找到
  • 浦东新区网站优化推广wordpress自适应框架
  • 济南一哥网站建设公司怎样下载手机app
  • 自己怎么做可以让百度收录的网站安康市集约化平台
  • 一屏式网站有什么好处智能设计平台
  • 室内设计招聘网站有哪些h5建站免费
  • 查询网站备案显示划横线发布新闻
  • 智能手机网站建设黑龙江 俄语网站制作