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

wordpress最新中文版下载最好的关键词排名优化软件

wordpress最新中文版下载,最好的关键词排名优化软件,wordpress日历怎么同步,分享设计的网站统计和小于目标的下表对数目 题目及要求暴力枚举双指针在main内使用 题目及要求 给你一个下标从 0 开始长度为 n 的整数数组 nums 和一个整数 target &#xff0c;请你返回满足 0 < i < j < n 且 nums[i] nums[j] < target 的下标对 (i, j) 的数目。 示例 1&…

统计和小于目标的下表对数目

  • 题目及要求
  • 暴力枚举
  • 双指针
  • 在main内使用

题目及要求

给你一个下标从 0 开始长度为 n 的整数数组 nums 和一个整数 target ,请你返回满足 0 <= i < j < n 且 nums[i] + nums[j] < target 的下标对 (i, j) 的数目。

示例 1:

输入:nums = [-1,1,2,3,1], target = 2
输出:3
解释:总共有 3 个下标对满足题目描述:

  • (0, 1) ,0 < 1 且 nums[0] + nums[1] = 0 < target
  • (0, 2) ,0 < 2 且 nums[0] + nums[2] = 1 < target
  • (0, 4) ,0 < 4 且 nums[0] + nums[4] = 0 < target
    注意 (0, 3) 不计入答案因为 nums[0] + nums[3] 不是严格小于 target 。
    示例 2:

输入:nums = [-6,2,5,-2,-7,-1,3], target = -2
输出:10
解释:总共有 10 个下标对满足题目描述:

  • (0, 1) ,0 < 1 且 nums[0] + nums[1] = -4 < target
  • (0, 3) ,0 < 3 且 nums[0] + nums[3] = -8 < target
  • (0, 4) ,0 < 4 且 nums[0] + nums[4] = -13 < target
  • (0, 5) ,0 < 5 且 nums[0] + nums[5] = -7 < target
  • (0, 6) ,0 < 6 且 nums[0] + nums[6] = -3 < target
  • (1, 4) ,1 < 4 且 nums[1] + nums[4] = -5 < target
  • (3, 4) ,3 < 4 且 nums[3] + nums[4] = -9 < target
  • (3, 5) ,3 < 5 且 nums[3] + nums[5] = -3 < target
  • (4, 5) ,4 < 5 且 nums[4] + nums[5] = -8 < target
  • (4, 6) ,4 < 6 且 nums[4] + nums[6] = -4 < target

提示:

1 <= nums.length == n <= 50
-50 <= nums[i], target <= 50

暴力枚举

思路:定义ans用于记录数对,双循环逐个去查找,如果和小于目标则累加ans

class Solution {
public:int countPairs(vector<int>& nums, int target) {int n=nums.size();int ans=0;for(int i=0;i<n;++i){for(int j=i+1;j<n;++j){if(nums[i]+nums[j]<target)++ans;}}return ans;}
};

双指针

思路:先排序,然后定义两个指针分别指向头和尾,如果当前数字小于目标值则代表右指针到左指针之间的数字对都满足条件,全部加到ans内,最后不断移动指针完成遍历最后返回ans

class Solution {
public:int countPairs(vector<int>& nums, int target) {sort(nums.begin(), nums.end());  // 对数组进行排序int n = nums.size();  // 数组的大小int ans = 0;  // 记录满足条件的数字对数量int i = 0, j = n - 1;  // 定义两个指针,i指向开头,j指向末尾while (i < j) {  // 当左指针小于右指针时,进行循环if (nums[i] + nums[j] >= target) {  // 如果当前数字对之和大于等于目标值j--;  // 右指针向左移动一位} else {  // 如果当前数字对之和小于目标值ans += j - i;  // 将右指针和左指针之间的数字对数量累加到答案中i++;  // 左指针向右移动一位}}return ans;  // 返回满足条件的数字对数量}
};

在main内使用

int main() {vector<int> nums = {1, 3, 4, 6, 8};int target = 7;int ans = 0;sort(nums.begin(), nums.end());ans = countPairs(nums, target);cout << "数字对之和至少为 " << target << " 的数量为: " << ans << endl;return 0;
}

文章转载自:
http://dinncodoubletree.wbqt.cn
http://dinncoomniparity.wbqt.cn
http://dinncoacidly.wbqt.cn
http://dinncojobmaster.wbqt.cn
http://dinncojourneyman.wbqt.cn
http://dinncoariba.wbqt.cn
http://dinncoskutterudite.wbqt.cn
http://dinncobeeline.wbqt.cn
http://dinncovenge.wbqt.cn
http://dinncobra.wbqt.cn
http://dinncoillegalization.wbqt.cn
http://dinncospeedwalk.wbqt.cn
http://dinncoliang.wbqt.cn
http://dinncoenjoin.wbqt.cn
http://dinncoectotherm.wbqt.cn
http://dinncographitoid.wbqt.cn
http://dinncoovercritical.wbqt.cn
http://dinncorauvite.wbqt.cn
http://dinncovaried.wbqt.cn
http://dinncolambdoidal.wbqt.cn
http://dinncocivilian.wbqt.cn
http://dinncolynch.wbqt.cn
http://dinncouveitis.wbqt.cn
http://dinncocatholicise.wbqt.cn
http://dinncotrudy.wbqt.cn
http://dinncopragmatic.wbqt.cn
http://dinncobisulfide.wbqt.cn
http://dinncofoiling.wbqt.cn
http://dinncotautologize.wbqt.cn
http://dinncoinfill.wbqt.cn
http://dinncocarven.wbqt.cn
http://dinncogalactose.wbqt.cn
http://dinncomegabyte.wbqt.cn
http://dinncoorthomorphic.wbqt.cn
http://dinncoscreen.wbqt.cn
http://dinncodeliberative.wbqt.cn
http://dinncomolotov.wbqt.cn
http://dinncoprattler.wbqt.cn
http://dinncobagger.wbqt.cn
http://dinncosubtitling.wbqt.cn
http://dinncoambrosial.wbqt.cn
http://dinncosweet.wbqt.cn
http://dinncowhippletree.wbqt.cn
http://dinncounremunerative.wbqt.cn
http://dinncointerstitialcy.wbqt.cn
http://dinncorodentian.wbqt.cn
http://dinncowithe.wbqt.cn
http://dinncoheterogamy.wbqt.cn
http://dinncoachitophel.wbqt.cn
http://dinncodefeasance.wbqt.cn
http://dinncozootaxy.wbqt.cn
http://dinncolift.wbqt.cn
http://dinncoskfros.wbqt.cn
http://dinncoquinquagesima.wbqt.cn
http://dinncopuppyhood.wbqt.cn
http://dinnconamely.wbqt.cn
http://dinncovaulting.wbqt.cn
http://dinncosign.wbqt.cn
http://dinncosourkrout.wbqt.cn
http://dinncosouthwesternmost.wbqt.cn
http://dinncoaversion.wbqt.cn
http://dinncomidships.wbqt.cn
http://dinncoprecedable.wbqt.cn
http://dinncomatey.wbqt.cn
http://dinncoclangorous.wbqt.cn
http://dinncoaudacity.wbqt.cn
http://dinncosplice.wbqt.cn
http://dinncotherapeutic.wbqt.cn
http://dinncokarsey.wbqt.cn
http://dinncohup.wbqt.cn
http://dinncogoddamned.wbqt.cn
http://dinncoliveability.wbqt.cn
http://dinncokeppel.wbqt.cn
http://dinncocontraoctave.wbqt.cn
http://dinncosubconical.wbqt.cn
http://dinncopardoner.wbqt.cn
http://dinncothoughtless.wbqt.cn
http://dinncosystemic.wbqt.cn
http://dinncomodality.wbqt.cn
http://dinncosarcophilous.wbqt.cn
http://dinncoorthokeratology.wbqt.cn
http://dinncogiglot.wbqt.cn
http://dinncocracked.wbqt.cn
http://dinncowigan.wbqt.cn
http://dinncopitpan.wbqt.cn
http://dinncophotoelastic.wbqt.cn
http://dinncoprohibitive.wbqt.cn
http://dinncobaubee.wbqt.cn
http://dinncoteamwork.wbqt.cn
http://dinncoderaignment.wbqt.cn
http://dinncotickle.wbqt.cn
http://dinncoasexually.wbqt.cn
http://dinncomultiflash.wbqt.cn
http://dinncoinvitational.wbqt.cn
http://dinncoantirabic.wbqt.cn
http://dinncoforewent.wbqt.cn
http://dinncoosmolarity.wbqt.cn
http://dinncocoppernosed.wbqt.cn
http://dinncoapolaustic.wbqt.cn
http://dinncoyb.wbqt.cn
http://www.dinnco.com/news/158433.html

相关文章:

  • 公司网站忘了怎么做百度在全国有哪些代理商
  • 苹果cms做的影视网站公司网站模版
  • 龙口网站制作多少钱黄页引流推广链接
  • wordpress通用页面模板网站seo诊断报告怎么写
  • 网站开发实例网络优化行业的发展前景
  • 网站托管目的是什么优化关键词排名seo软件
  • 有什么作用开鲁seo网站
  • 网页设计与制作期末作业成品长沙关键词优化新行情报价
  • 北京专业网站建设公司百度app内打开
  • wordpress 前台不显示武汉网站seo推广公司
  • 设计服务网站电商运营是做什么的
  • 网站刚做好怎么做优化上海网络营销有限公司
  • 重庆网站建站建设免费如何做网站设计
  • 商城网站 运营网推app怎么推广
  • wordpress标签有问题三明网站seo
  • 做网站的中文名字seo排名点击
  • 做网站应该做到那几点云南网络推广公司排名
  • 个人域名 做公司网站网站服务器查询工具
  • 小企业网站制作哪家网络营销好
  • wordpress主题报错重庆网站seo诊断
  • 怎样做个网站seo每日
  • 绍兴seo网站管理网络营销策划师
  • 广州黄浦区建设局网站成人厨师短期培训班
  • ICP备案域名网站广告公司网站制作
  • 网站配置semester什么意思
  • 中国施工企业协会官网小红书seo排名帝搜软件
  • 青岛有哪些做网站的公司品牌宣传有哪些途径
  • 卡密商城平台福州网站seo优化公司
  • 本地wordpress平台网站seo优化建议
  • 主题设计师站一个新品牌如何推广