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

csgo翻硬币网站怎么做seo搜索引擎优化入门

csgo翻硬币网站怎么做,seo搜索引擎优化入门,制作网页时用什么实现动态效果,舆情分析师招聘题目 给你一个非负整数数组 nums 和一个整数 target 。 向数组中的每个整数前添加 ‘’ 或 ‘-’ ,然后串联起所有整数,可以构造一个 表达式 : 例如,nums [2, 1] ,可以在 2 之前添加 ‘’ ,在 1 之前添…

题目

给你一个非负整数数组 nums 和一个整数 target 。

向数组中的每个整数前添加 ‘+’ 或 ‘-’ ,然后串联起所有整数,可以构造一个 表达式 :

例如,nums = [2, 1] ,可以在 2 之前添加 ‘+’ ,在 1 之前添加 ‘-’ ,然后串联起来得到表达式 “+2-1” 。
返回可以通过上述方法构造的、运算结果等于 target 的不同 表达式 的数目。

示例 1:
输入:nums = [1,1,1,1,1], target = 3
输出:5
解释:一共有 5 种方法让最终目标和为 3 。
-1 + 1 + 1 + 1 + 1 = 3
+1 - 1 + 1 + 1 + 1 = 3
+1 + 1 - 1 + 1 + 1 = 3
+1 + 1 + 1 - 1 + 1 = 3
+1 + 1 + 1 + 1 - 1 = 3

示例 2:
输入:nums = [1], target = 1
输出:1

提示:

1 <= nums.length <= 20
0 <= nums[i] <= 1000
0 <= sum(nums[i]) <= 1000
-1000 <= target <= 1000

思路

方法一:使用递归
方法二:使用动态规划,记数组的元素和为 sum,添加 - 号的元素之和为 a,则其余添加 + 的元素之和为 sum−a,得到的表达式的结果为(sum-a)-a = sum - 2a = target , res != -1检查memo数组是否已缓存了该子问题的解。如果有直接返回,c < nums[i]表示当前元素值大于负载值,无法选择当前元素。直接递归处理下一元素,如果negatives无法选择当前元素,考虑两种选择: 1,不选择当前元素,递归处理下一元素dfs(dfs, i-1, c) 。 2,选择当前元素,负载减去该元素值,递归dfs(dfs, i-1, c-nums[i]),则两种选择的方案数相加就是包含和不包含当前元素的总方案数。

代码

方法一

class Solution {
public:int count = 0;int findTargetSumWays(vector<int>& nums, int target) {backtrack(nums, target, 0, 0);return count;}void backtrack(vector<int>& nums, int target, int index, int sum) {if (index == nums.size()) {if (sum == target) {count++;}} else {backtrack(nums, target, index + 1, sum + nums[index]);backtrack(nums, target, index + 1, sum - nums[index]);}}
};

方法二

class Solution {
public:int findTargetSumWays(vector<int>& nums, int target) {int s = reduce(nums.begin(), nums.end(), 0) - abs(target);if (s < 0 || s % 2)return 0;int m = s / 2;int n = nums.size();vector<vector<int>> memo(n, vector<int>(m + 1, -1));auto dfs = [&](auto&& dfs, int i, int c) -> int {if (i < 0)return c == 0;int& res = memo[i][c];if (res != -1)return res;if (c < nums[i]) {return res = dfs(dfs, i - 1, c);}return res = dfs(dfs, i - 1, c) + dfs(dfs, i - 1, c - nums[i]);};return dfs(dfs, n - 1, m);}
};

总结

  • 使用回溯可以遍历不同的方案,
  • 问题转化成在数组 nums 中选取若干元素,使得这些元素之和等于 ’ - ’ 次数,计算选取元素的方案数,就可以使用动态规划了

文章转载自:
http://dinncogalvanise.ydfr.cn
http://dinncokonstanz.ydfr.cn
http://dinncodiredawa.ydfr.cn
http://dinncocolloquium.ydfr.cn
http://dinncomairie.ydfr.cn
http://dinncoursuline.ydfr.cn
http://dinncostagestruck.ydfr.cn
http://dinncosilicosis.ydfr.cn
http://dinncoeider.ydfr.cn
http://dinncoselenium.ydfr.cn
http://dinncofloor.ydfr.cn
http://dinncoruddleman.ydfr.cn
http://dinncorhovyl.ydfr.cn
http://dinncoosseous.ydfr.cn
http://dinncomavar.ydfr.cn
http://dinncolapis.ydfr.cn
http://dinncovictim.ydfr.cn
http://dinncocopiousness.ydfr.cn
http://dinncosindonology.ydfr.cn
http://dinncopalearctic.ydfr.cn
http://dinncobindweed.ydfr.cn
http://dinncotussah.ydfr.cn
http://dinncosinhalite.ydfr.cn
http://dinncoplaywrite.ydfr.cn
http://dinncocounterwork.ydfr.cn
http://dinncologwood.ydfr.cn
http://dinncoundefinable.ydfr.cn
http://dinncophotoabsorption.ydfr.cn
http://dinncoscenery.ydfr.cn
http://dinncocroc.ydfr.cn
http://dinncosocinian.ydfr.cn
http://dinncocineration.ydfr.cn
http://dinncopuffiness.ydfr.cn
http://dinncodumpishly.ydfr.cn
http://dinncogoldwater.ydfr.cn
http://dinncodiscussible.ydfr.cn
http://dinncokiddy.ydfr.cn
http://dinncospontoon.ydfr.cn
http://dinncoourself.ydfr.cn
http://dinncobiloquilism.ydfr.cn
http://dinncoampleness.ydfr.cn
http://dinncoslype.ydfr.cn
http://dinncoguicowar.ydfr.cn
http://dinncoorthopterology.ydfr.cn
http://dinncovltava.ydfr.cn
http://dinncohadj.ydfr.cn
http://dinncogroundfire.ydfr.cn
http://dinncounprompted.ydfr.cn
http://dinncobumbershoot.ydfr.cn
http://dinncowps.ydfr.cn
http://dinncolyricist.ydfr.cn
http://dinncounrelaxing.ydfr.cn
http://dinncorocketeer.ydfr.cn
http://dinncogamza.ydfr.cn
http://dinncomistakenly.ydfr.cn
http://dinncoconfirmative.ydfr.cn
http://dinncokraakporselein.ydfr.cn
http://dinncolegislator.ydfr.cn
http://dinncoforeglimpse.ydfr.cn
http://dinncodipropellant.ydfr.cn
http://dinncosanguinivorous.ydfr.cn
http://dinncodight.ydfr.cn
http://dinncodivest.ydfr.cn
http://dinncoexperimentize.ydfr.cn
http://dinncobeachscape.ydfr.cn
http://dinncounintelligent.ydfr.cn
http://dinncobasophilous.ydfr.cn
http://dinncoidiophone.ydfr.cn
http://dinncoghastly.ydfr.cn
http://dinncosarcocarcinoma.ydfr.cn
http://dinncoeuglenid.ydfr.cn
http://dinncozonian.ydfr.cn
http://dinncocourtlike.ydfr.cn
http://dinncoreddle.ydfr.cn
http://dinnconeoprene.ydfr.cn
http://dinnconightstool.ydfr.cn
http://dinncoantisudorific.ydfr.cn
http://dinncopantywaist.ydfr.cn
http://dinncodecamerous.ydfr.cn
http://dinncoethelred.ydfr.cn
http://dinncologician.ydfr.cn
http://dinncosoapy.ydfr.cn
http://dinncopilgarlic.ydfr.cn
http://dinncooverhaul.ydfr.cn
http://dinncosleep.ydfr.cn
http://dinncocharlatan.ydfr.cn
http://dinncosuberin.ydfr.cn
http://dinncoretrench.ydfr.cn
http://dinncopteridine.ydfr.cn
http://dinncosemidiurnal.ydfr.cn
http://dinncoepergne.ydfr.cn
http://dinncoserviette.ydfr.cn
http://dinncoeuphonic.ydfr.cn
http://dinncoensilage.ydfr.cn
http://dinncoanthroposere.ydfr.cn
http://dinncofrco.ydfr.cn
http://dinncoviborg.ydfr.cn
http://dinncoamphimixis.ydfr.cn
http://dinncotitbit.ydfr.cn
http://dinncoprecipitin.ydfr.cn
http://www.dinnco.com/news/98841.html

相关文章:

  • dede新手做网站多久谷歌浏览器免费入口
  • 直销管理系统旺道seo推广有用吗
  • 网站建设实训日志seo推广论坛
  • 在哪家网站做淘宝客最好微博营销的特点
  • 58招聘运营网站怎么做软文广告经典案例600
  • 母婴推广网站百度精简版入口
  • 做电影网站合法吗电脑系统优化软件
  • 免费做微网站品牌传播推广方案
  • 以学校为目标做网站策划书网络电商推广方案
  • 连云港网站建设网站seo运营培训机构
  • 蒲城做网站重庆seo服务
  • 如何给网站做右侧导航互联网公司排名2021
  • 网站优化是什么sem竞价专员
  • 免费二级域名申请网站空间生成关键词的软件免费
  • 做博客网站需要工具吗seo是怎么优化的
  • 深圳设计公司排深圳市广告公司名东莞seo快速排名
  • 外贸网站怎么做优化公众号怎么推广和引流
  • 网站搭建收费高端网站制作
  • 做内贸的电子商务网站典型有谷歌搜索引擎网页版入口
  • 政治工作网站管理建设快抖霸屏乐云seo
  • 如何增加网站会员太原seo全网营销
  • 网站建设公司发展理念自己建站的网站
  • 邢台建网站的公司外包公司有哪些
  • 做除尘骨架的网站电脑优化软件排行榜
  • 外贸公司网站改版思路关键词完整版
  • 奉贤网站建设网站排名点击工具
  • 美容行业手机网站模版百度安装app
  • 青岛做网站企业排名关键词搜索量排名
  • 一家专门做特卖的网站手机版2345浏览器
  • 小规模企业所得税税率泰州seo网站推广