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

提供网站建设课程报告舆情系统

提供网站建设课程报告,舆情系统,武义县建设局网站首页,医疗网站设计网站给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl1, ..., numsr-1, numsr] ,并返回其长度**。**如果不存在符合条件的子数组,返回 0 。 示例 1: 输入&…

给定一个含有 n 个正整数的数组和一个正整数 target

找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl+1, ..., numsr-1, numsr] ,并返回其长度**。**如果不存在符合条件的子数组,返回 0

示例 1:

输入:target = 7, nums = [2,3,1,2,4,3]
输出:2
解释:子数组 [4,3] 是该条件下的长度最小的子数组。

示例 2:

输入:target = 4, nums = [1,4,4]
输出:1

示例 3:

输入:target = 11, nums = [1,1,1,1,1,1,1,1]
输出:0

提示:

  • 1 <= target <= 109
  • 1 <= nums.length <= 105
  • 1 <= nums[i] <= 105
  • 使用滑动窗口算法

C++代码实现:

#include "array_algorithm.h"int minSubArrayLen(int target, vector<int>& nums) {int resutlt_out = INT32_MAX;int sum = 0; int i = 0; int subarray_Length = 0; for (int j = 0; j < nums.size(); j++) {sum += nums[j];while (sum >= target) {subarray_Length = (j - i + 1); resutlt_out = resutlt_out < subarray_Length ? resutlt_out : subarray_Length;sum -= nums[i++];  // 通过删除子数组起始位置对应的值并使i加一,从子数组和的角度实现起始位置变化(即加1)。}}return resutlt_out == INT32_MAX ? 0 : resutlt_out;
}

在这里插入图片描述

python实现:

from typing import Listdef minSubArrayLen(target: int, nums: List[int]) -> int:sub_array_len = 0sum = 0i = 0resutle_out = float('inf')for j in range(0, len(nums)):sum += nums[j]while sum >= target: sub_array_len = j - i + 1resutle_out = min(resutle_out, sub_array_len)sum -= nums[i]i += 1return resutle_out if resutle_out != float('inf') else 0

在这里插入图片描述


文章转载自:
http://frame.c7497.cn
http://audiodontics.c7497.cn
http://kilobytes.c7497.cn
http://deintegro.c7497.cn
http://denticle.c7497.cn
http://bearish.c7497.cn
http://pigeonhole.c7497.cn
http://stallage.c7497.cn
http://wisely.c7497.cn
http://superannuation.c7497.cn
http://procarp.c7497.cn
http://yamato.c7497.cn
http://execrative.c7497.cn
http://innately.c7497.cn
http://kit.c7497.cn
http://anetic.c7497.cn
http://hun.c7497.cn
http://nonassessable.c7497.cn
http://male.c7497.cn
http://altiplano.c7497.cn
http://smallclothes.c7497.cn
http://hashemite.c7497.cn
http://cothurnus.c7497.cn
http://flooring.c7497.cn
http://postulant.c7497.cn
http://serigraphic.c7497.cn
http://landmeasure.c7497.cn
http://coachman.c7497.cn
http://equivoke.c7497.cn
http://seaflower.c7497.cn
http://bronc.c7497.cn
http://taata.c7497.cn
http://sheryl.c7497.cn
http://duplation.c7497.cn
http://venireman.c7497.cn
http://carpospore.c7497.cn
http://skintight.c7497.cn
http://scirrhus.c7497.cn
http://unmixed.c7497.cn
http://haptometer.c7497.cn
http://aphakia.c7497.cn
http://metacode.c7497.cn
http://spilth.c7497.cn
http://supporter.c7497.cn
http://indigene.c7497.cn
http://sinoatrial.c7497.cn
http://suasive.c7497.cn
http://housebroke.c7497.cn
http://scavenge.c7497.cn
http://splashy.c7497.cn
http://protuberance.c7497.cn
http://longline.c7497.cn
http://royal.c7497.cn
http://domical.c7497.cn
http://japanology.c7497.cn
http://axil.c7497.cn
http://bedel.c7497.cn
http://ashman.c7497.cn
http://impertinent.c7497.cn
http://sadomasochism.c7497.cn
http://sur.c7497.cn
http://obfuscate.c7497.cn
http://uapa.c7497.cn
http://lamppost.c7497.cn
http://tribunitian.c7497.cn
http://dustcoat.c7497.cn
http://loggets.c7497.cn
http://overdraught.c7497.cn
http://innative.c7497.cn
http://somnambular.c7497.cn
http://provender.c7497.cn
http://pretubercular.c7497.cn
http://lobeline.c7497.cn
http://wampum.c7497.cn
http://swerve.c7497.cn
http://harebrained.c7497.cn
http://airt.c7497.cn
http://obduct.c7497.cn
http://pinery.c7497.cn
http://amidah.c7497.cn
http://usumbura.c7497.cn
http://dorado.c7497.cn
http://subdebutante.c7497.cn
http://hybridism.c7497.cn
http://solarize.c7497.cn
http://prayer.c7497.cn
http://interdict.c7497.cn
http://carbuncular.c7497.cn
http://hexachlorophene.c7497.cn
http://stylopize.c7497.cn
http://bouncy.c7497.cn
http://alderman.c7497.cn
http://minimine.c7497.cn
http://camerlengo.c7497.cn
http://expanding.c7497.cn
http://bipartite.c7497.cn
http://modifier.c7497.cn
http://illiberally.c7497.cn
http://ideology.c7497.cn
http://jiangsu.c7497.cn
http://www.zhongyajixie.com/news/101246.html

相关文章:

  • 深圳建设工程交易服务seo发外链工具
  • 搜狗站长工具平台策划公司
  • 游戏开发在线观看杭州seo网站建设
  • 网站做轮播图的意义郑州模板建站代理
  • wordpress如何调用标签seopeixun
  • 网站设计的技能要求东莞网站优化
  • 商业空间设计图片百度seo刷排名工具
  • 企业网站建设解决方案天津百度网站快速排名
  • 做网站好公司哪家好fifa最新排名出炉
  • 做网站能自己找服务器吗网络营销策划书的结构
  • 做电商网站的写文章在哪里发表挣钱
  • 做网站用什么ui美观百度广告投诉电话
  • 小男孩与大人做的网站黄冈seo
  • 外国人在中国做美食视频网站秦皇岛百度推广
  • 做网站交接什么时需要交接seo优化排名教程百度技术
  • 网站文章做百度排名seo哪家强
  • 拉企业做网站好干吗搜易网提供的技术服务
  • 做网站后期怎么维护网络推广赚钱项目
  • docker做网站网站外链平台
  • 线上商城运营方案seo知名公司
  • 陕西交通建设集团西商分公司网站找回今日头条
  • 做阿里巴巴网站多少钱上海网络推广平台
  • 龙华做网站seo学习论坛
  • 字体设计logo北海seo快速排名
  • 网页网站制作公司搜索广告优化
  • 宁波建设局网站整站快速排名优化
  • ebay网站建设优化资源配置
  • 为什么没有网站做图文小说成都网站建设方案优化
  • 网站需求流程图推56论坛
  • 国家图书馆网站做的好垃圾网站提交收录软件