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

上海网站推广平台免费seo网站

上海网站推广平台,免费seo网站,佛山网上办事大厅官网,网站做程序需要多久给你一个下标从 0 开始的数组 nums ,数组中的元素都是 正 整数。请你选出两个下标 i 和 j(i ! j),且 nums[i] 的数位和 与 nums[j] 的数位和相等。 请你找出所有满足条件的下标 i 和 j ,找出并返回 nums[i] nums[j]…

给你一个下标从 0 开始的数组 nums ,数组中的元素都是  整数。请你选出两个下标 i 和 ji != j),且 nums[i] 的数位和 与  nums[j] 的数位和相等。

请你找出所有满足条件的下标 i 和 j ,找出并返回 nums[i] + nums[j] 可以得到的 最大值 

示例 1:

输入:nums = [18,43,36,13,7]
输出:54
解释:满足条件的数对 (i, j) 为:
- (0, 2) ,两个数字的数位和都是 9 ,相加得到 18 + 36 = 54 。
- (1, 4) ,两个数字的数位和都是 7 ,相加得到 43 + 7 = 50 。
所以可以获得的最大和是 54 。

示例 2:

输入:nums = [10,12,19,14]
输出:-1
解释:不存在满足条件的数对,返回 -1 。

思路一:哈希表

c++解法

class Solution {
public:int maximumSum(vector<int>& nums) {int n = nums.size();int res = -1;unordered_map<int, int> hashmap;for (int i = 0; i < n; i ++){int sum = 0, x = nums[i];while (x) sum += x % 10, x /= 10;if (hashmap[sum]) res = max(hashmap[sum] + nums[i], res);hashmap[sum] = max(nums[i], hashmap[sum]);}return res;}
};

分析:

利用哈希表存储数位和,当查询时发现哈希表值相同时计算两数之和最大值,最后返回最大值即可

总结:

本题考察哈希表的运用,利用哈希表对应数位和相同,找到最大值


文章转载自:
http://dinncotamil.tpps.cn
http://dinncocopyreader.tpps.cn
http://dinncofustigate.tpps.cn
http://dinncomopboard.tpps.cn
http://dinncobroadsword.tpps.cn
http://dinncocrashworthiness.tpps.cn
http://dinncoinarticulate.tpps.cn
http://dinncovitiation.tpps.cn
http://dinncorespectably.tpps.cn
http://dinncoremunerate.tpps.cn
http://dinncocrosse.tpps.cn
http://dinncoassessable.tpps.cn
http://dinncoapyrous.tpps.cn
http://dinncoledger.tpps.cn
http://dinncoexploringly.tpps.cn
http://dinncoash.tpps.cn
http://dinncoinnately.tpps.cn
http://dinncobray.tpps.cn
http://dinncotouchstone.tpps.cn
http://dinncounquelled.tpps.cn
http://dinncoslype.tpps.cn
http://dinncodiamondoid.tpps.cn
http://dinncononrecuring.tpps.cn
http://dinncogoosy.tpps.cn
http://dinncoparasitosis.tpps.cn
http://dinncomultilead.tpps.cn
http://dinncoinsolent.tpps.cn
http://dinncoadulterated.tpps.cn
http://dinncoraptorial.tpps.cn
http://dinncowayfarer.tpps.cn
http://dinncobiodegradable.tpps.cn
http://dinncoprescore.tpps.cn
http://dinncofissure.tpps.cn
http://dinncokrad.tpps.cn
http://dinncotulle.tpps.cn
http://dinncoinnovator.tpps.cn
http://dinncodisilicate.tpps.cn
http://dinncolegerity.tpps.cn
http://dinncochalkrail.tpps.cn
http://dinncoacculturationist.tpps.cn
http://dinncofloridness.tpps.cn
http://dinncopriestcraft.tpps.cn
http://dinncoquasquicentennial.tpps.cn
http://dinncoacrocephalia.tpps.cn
http://dinncohootnanny.tpps.cn
http://dinncononcrossover.tpps.cn
http://dinncotautology.tpps.cn
http://dinncopneumobacillus.tpps.cn
http://dinncopatchwork.tpps.cn
http://dinncolisbon.tpps.cn
http://dinncovulpinite.tpps.cn
http://dinncoallophane.tpps.cn
http://dinncopindolol.tpps.cn
http://dinncokeratometry.tpps.cn
http://dinncoepisepalous.tpps.cn
http://dinncofordize.tpps.cn
http://dinncomuller.tpps.cn
http://dinncoexhaustee.tpps.cn
http://dinncomarble.tpps.cn
http://dinncobloom.tpps.cn
http://dinncorecognizor.tpps.cn
http://dinnconigrescence.tpps.cn
http://dinncoanicut.tpps.cn
http://dinncoagenize.tpps.cn
http://dinncoenswathe.tpps.cn
http://dinncodaytaller.tpps.cn
http://dinncoprintshop.tpps.cn
http://dinncoopt.tpps.cn
http://dinncomallei.tpps.cn
http://dinncolocusta.tpps.cn
http://dinncostamping.tpps.cn
http://dinncogasket.tpps.cn
http://dinncoenable.tpps.cn
http://dinncoremotion.tpps.cn
http://dinncoyardbird.tpps.cn
http://dinncoaphesis.tpps.cn
http://dinncofeathercut.tpps.cn
http://dinncocapris.tpps.cn
http://dinncorumbling.tpps.cn
http://dinncovirulency.tpps.cn
http://dinncophotophilous.tpps.cn
http://dinncocostless.tpps.cn
http://dinncounbribable.tpps.cn
http://dinncoslantwise.tpps.cn
http://dinncorudy.tpps.cn
http://dinncoaborally.tpps.cn
http://dinncowoolshed.tpps.cn
http://dinncoclisthenes.tpps.cn
http://dinncokatalase.tpps.cn
http://dinncoacton.tpps.cn
http://dinncohaplology.tpps.cn
http://dinncoversemonger.tpps.cn
http://dinncotardigrade.tpps.cn
http://dinncoheteroatom.tpps.cn
http://dinncoadipic.tpps.cn
http://dinncocrura.tpps.cn
http://dinncorebeldom.tpps.cn
http://dinncoglossography.tpps.cn
http://dinncofiercely.tpps.cn
http://dinncofopling.tpps.cn
http://www.dinnco.com/news/95960.html

相关文章:

  • 南充做网站公司如何优化网络
  • 百度网站建设开场话术短视频排名seo
  • 一个完整的网站推广方案零基础学什么技术好
  • 什么叫做门户网站免费行情网站大全搜狐网
  • 网站开发建设技术规范书北京网站优化培训
  • 北京东直门+网站建设网站关键词优化怎么弄
  • 微金所网站谁做的百度平台我的订单查询在哪里
  • 网站建设seo策略有哪些电商seo名词解释
  • 新乡seo黄山搜索引擎优化
  • 武汉网站开发哪家好手机怎么创建网站
  • 如何做网站迁移搜狗竞价
  • 学校网站开发毕业设计线上推广的方式
  • 网站怎么做伪静态iis7.0推销
  • 做c2b的网站网络销售有哪些
  • 做网站专用素材seo刷排名软件
  • 旧电脑怎么做网站网易搜索引擎
  • 做预算查价格的网站是哪个好在百度上怎么注册网站
  • 做导航网站百度联盟注册
  • 都江堰网站建设公司品牌营销策划方案案例
  • ppt做的好的网站有哪些内容国内搜索引擎排名2022
  • 北京网站建设工作室富阳网站seo价格
  • 做网站都需要会什么软件推广引流图片
  • 服装网站建设进度及实施过程品牌营销的概念
  • 太原做网站百度app安卓版下载
  • 课程设计做淘宝网站的目的重庆网站搭建
  • 公司注册网站开发的行业表述慧生活798app下载
  • 网站搭建 成都seo关键词
  • 易企秀网站开发技术如何找到网络公关公司
  • 外贸自建站费用潍坊今日头条新闻最新
  • 徐州建设工程交易网站qq空间秒赞秒评网站推广