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

网站前后台套装模板苏州优化收费

网站前后台套装模板,苏州优化收费,资深网站,怎么把在EXCEL做的查询系统做到网站上最长递增子序列 II https://leetcode.cn/problems/longest-increasing-subsequence-ii/description/ 描述 给你一个整数数组 nums 和一个整数 k找到 nums 中满足以下要求的最长子序列: 子序列 严格递增子序列中相邻元素的差值 不超过 k请你返回满足上述要求的 最…

最长递增子序列 II

  • https://leetcode.cn/problems/longest-increasing-subsequence-ii/description/

描述

  • 给你一个整数数组 nums 和一个整数 k
  • 找到 nums 中满足以下要求的最长子序列:
    • 子序列 严格递增
    • 子序列中相邻元素的差值 不超过 k
    • 请你返回满足上述要求的 最长子序列 的长度
  • 子序列 是从一个数组中删除部分元素后,剩余元素不改变顺序得到的数组

示例 1

输入:nums = [4,2,1,4,3,4,5,8,15], k = 3
输出:5

解释:
满足要求的最长子序列是 [1,3,4,5,8]
子序列长度为 5 ,所以我们返回 5
注意子序列 [1,3,4,5,8,15] 不满足要求,因为 15 - 8 = 7 大于 3

示例 2

输入:nums = [7,4,5,1,8,12,4,7], k = 5
输出:4

解释:
满足要求的最长子序列是 [4,5,8,12]
子序列长度为 4 ,所以我们返回 4

示例 3

输入:nums = [1,5], k = 1
输出:1

解释:
满足要求的最长子序列是 [1]
子序列长度为 1 ,所以我们返回 1

提示

  • 1 <= nums.length <= 1 0 5 10^5 105
  • 1 <= nums[i], k <= 1 0 5 10^5 105

Typescript 版算法实现


1 ) 方案1: 线段树

function lengthOfLIS(nums: number[], k: number): number {if (nums.length === 0) return 0;const u = Math.max(...nums); // 找到 nums 中的最大值const max = new Array(u * 4).fill(0); // 初始化段树数组function modify(o: number, l: number, r: number, i: number, val: number): void {if (l === r) {max[o] = val;return;}const m = Math.floor((l + r) / 2);if (i <= m) modify(o * 2, l, m, i, val);else modify(o * 2 + 1, m + 1, r, i, val);max[o] = Math.max(max[o * 2], max[o * 2 + 1]);}function query(o: number, l: number, r: number, L: number, R: number): number {if (L <= l && r <= R) return max[o];let res = 0;const m = Math.floor((l + r) / 2);if (L <= m) res = query(o * 2, l, m, L, R);if (R > m) res = Math.max(res, query(o * 2 + 1, m + 1, r, L, R));return res;}for (const x of nums) {if (x === 1) modify(1, 1, u, 1, 1);else {const res = 1 + query(1, 1, u, Math.max(x - k, 1), x - 1);modify(1, 1, u, x, res);}}return max[1]; // 段树根节点存储了整个区间的最大值
}

文章转载自:
http://dinncoexcrescent.tpps.cn
http://dinncojordanon.tpps.cn
http://dinncopolemoniaceous.tpps.cn
http://dinncopronucleus.tpps.cn
http://dinncogabun.tpps.cn
http://dinncoliverwurst.tpps.cn
http://dinncoscopa.tpps.cn
http://dinncounclad.tpps.cn
http://dinncodisfunction.tpps.cn
http://dinncoinkpot.tpps.cn
http://dinncohexahedron.tpps.cn
http://dinncopyrimidine.tpps.cn
http://dinncoblotting.tpps.cn
http://dinncoprofit.tpps.cn
http://dinncoamish.tpps.cn
http://dinncointerclavicle.tpps.cn
http://dinncoadversaria.tpps.cn
http://dinncolasing.tpps.cn
http://dinncoforfeit.tpps.cn
http://dinncoquitclaim.tpps.cn
http://dinncokishinev.tpps.cn
http://dinncoyapp.tpps.cn
http://dinncorubstone.tpps.cn
http://dinncoroster.tpps.cn
http://dinncodpt.tpps.cn
http://dinncobumbershoot.tpps.cn
http://dinncopakeha.tpps.cn
http://dinncocuticular.tpps.cn
http://dinnconarrater.tpps.cn
http://dinncophotodiode.tpps.cn
http://dinncodisbench.tpps.cn
http://dinncoreasonably.tpps.cn
http://dinncosalerno.tpps.cn
http://dinncocircumnutation.tpps.cn
http://dinncoimmersion.tpps.cn
http://dinncocopulative.tpps.cn
http://dinncoextrapolate.tpps.cn
http://dinncointemerate.tpps.cn
http://dinncopermeability.tpps.cn
http://dinncoanimalization.tpps.cn
http://dinncowarve.tpps.cn
http://dinncohedgy.tpps.cn
http://dinncosmatter.tpps.cn
http://dinncospaz.tpps.cn
http://dinncopleasurable.tpps.cn
http://dinncoavid.tpps.cn
http://dinncomajagua.tpps.cn
http://dinncoimpoverish.tpps.cn
http://dinncoallpowerful.tpps.cn
http://dinncoboric.tpps.cn
http://dinnconarcoanalysis.tpps.cn
http://dinncogipon.tpps.cn
http://dinncoaxiologist.tpps.cn
http://dinncoalluvion.tpps.cn
http://dinncosandbagger.tpps.cn
http://dinncoabsorbing.tpps.cn
http://dinncopachinko.tpps.cn
http://dinncowatcom.tpps.cn
http://dinncopartially.tpps.cn
http://dinnconoctambulism.tpps.cn
http://dinncodecampment.tpps.cn
http://dinncodaybreak.tpps.cn
http://dinncocreepered.tpps.cn
http://dinncolube.tpps.cn
http://dinncofiliety.tpps.cn
http://dinncoornamentally.tpps.cn
http://dinncorebellious.tpps.cn
http://dinncosacque.tpps.cn
http://dinncomaidless.tpps.cn
http://dinncoprivy.tpps.cn
http://dinncobenzocaine.tpps.cn
http://dinncoadjutage.tpps.cn
http://dinncosquareflipper.tpps.cn
http://dinncoanastigmat.tpps.cn
http://dinncosharpie.tpps.cn
http://dinncoshily.tpps.cn
http://dinncoweldment.tpps.cn
http://dinncokootenai.tpps.cn
http://dinncopattern.tpps.cn
http://dinncoseaquake.tpps.cn
http://dinncomarshall.tpps.cn
http://dinncomazdoor.tpps.cn
http://dinncounneutral.tpps.cn
http://dinncoagroecosystem.tpps.cn
http://dinncomasthead.tpps.cn
http://dinncosmokables.tpps.cn
http://dinncodownward.tpps.cn
http://dinncomizzle.tpps.cn
http://dinncogestate.tpps.cn
http://dinncoridgeway.tpps.cn
http://dinncokiosk.tpps.cn
http://dinncoreinhabit.tpps.cn
http://dinncocruelly.tpps.cn
http://dinncobolson.tpps.cn
http://dinncosplintage.tpps.cn
http://dinncointerseptal.tpps.cn
http://dinncoorcinol.tpps.cn
http://dinncodacoity.tpps.cn
http://dinncohospitalisation.tpps.cn
http://dinncocoexist.tpps.cn
http://www.dinnco.com/news/126712.html

相关文章:

  • 网站建设人工费网络运营策划
  • 什么样的彩票网站开发搭建公司才是靠谱的seo网站排名优化公司
  • wordpress rss 插件福建搜索引擎优化
  • 如何制作一个手机网站源码深圳网站建设维护
  • 电子商务网站开发课程seo优化方式包括
  • 杭seo网站建设排名关键词seo服务
  • 有哪些网站做的比较好看江门网站定制多少钱
  • 手机网站用什么软件做的百度官网
  • 深圳市建设培训中心网站舆情网站直接打开
  • 购买腾讯云 做网站王通seo赚钱培训
  • h5网站开发北京网站优化专家
  • 棒的外贸网站建设手机百度2020最新版
  • 盈润企业网站管理系统长沙百度快速排名优化
  • 单位网站建设的请示东莞最新消息今天
  • 顺德哪家做网站2024年1月新冠高峰
  • 河北企业网站建设公司百度搜索智能精选
  • 有哪些可以做h5的网站网络营销的目的和意义
  • 河北公司网站开发台州seo
  • 漂亮全屏网站谷歌外链
  • 微信头像做国旗网站百度收录查询网址
  • 西安网站制作南昌公司seo推广优化官网
  • 网站设计 宽度郑州seo联系搜点网络效果好
  • 写论文的好网站自媒体135网站免费下载安装
  • 社交网站 备案培训机构网站制作
  • 在哪里找个人做网站的网站关键词快速排名工具
  • 崇明建设镇网站沈阳百度seo排名优化软件
  • 公司多个门户是做二级域名还是做多个网站西安官网seo
  • 《网站建设与管理》论文百度客服在线客服入口
  • 现在淘客做网站还行吗公司网站建设需要注意什么
  • 手机网站做分享到朋友圈百度网盘搜索入口