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

商城属于电商网站吗google chrome网页版

商城属于电商网站吗,google chrome网页版,企业营销战略,个人网站价格目录 一、3438. 找到字符串中合法的相邻数字二、3439. 重新安排会议得到最多空余时间 I三、3440. 重新安排会议得到最多空余时间 II四、3441. 变成好标题的最少代价 一、3438. 找到字符串中合法的相邻数字 题目链接 本题有两个条件: 相邻数字互不相同两个数字的的…

目录

  • 一、3438. 找到字符串中合法的相邻数字
  • 二、3439. 重新安排会议得到最多空余时间 I
  • 三、3440. 重新安排会议得到最多空余时间 II
  • 四、3441. 变成好标题的最少代价

一、3438. 找到字符串中合法的相邻数字

题目链接
在这里插入图片描述
本题有两个条件:

  • 相邻数字互不相同
  • 两个数字的的出现次数等于数字本身

先预处理字符串 s s s 中每个字符的出现次数,再从左往右两两枚举,返回第一个满足上述条件的相邻数字,没有返回空字符串。

代码如下:

class Solution {public String findValidPair(String s) {int[] cnt = new int[10];for(char c : s.toCharArray()){cnt[c-'0']++;}for(int i=1; i<s.length(); i++){int x = s.charAt(i) - '0';int y = s.charAt(i-1) - '0';if(x == y) continue;if(cnt[x] == x && cnt[y] == y)return s.substring(i-1, i+1);}return "";}
}

二、3439. 重新安排会议得到最多空余时间 I

题目链接
在这里插入图片描述
题目求至多平移 k k k 个会议后,可以获得的最大空余时间,与会议本身的时间无关,可以预处理出会议之间的空余时间(注:不要忘记第一个会议开始前和最后一个会议结束后的空余时间),贪心的想,平移的会议越多,可以获得的空余时间越大,此时题目变成了平移 k k k 个会议后,可以获得的最大空余时间,讨论 k k k 的大小:

  • k = 1 k=1 k=1,对于 1 1 1 个会议来说,无论它往前移还是往后移,它会使得连续的 2 2 2 段空余时间合并.
  • k = 2 k=2 k=2,对于 2 2 2 个会议来说,无论它们往前移还是往后移,它会使得连续的 3 3 3 段空余时间合并.
  • 对于 k k k 个会议来说,无论它们往前移还是往后移,它会使得连续的 k + 1 k+1 k+1 段空余时间合并.

也就是说它其实是一个滑动窗口题,就是维护连续 k + 1 k+1 k+1 段空余时间的最大值。

代码如下:

class Solution {public int maxFreeTime(int event, int k, int[] start, int[] end) {int n = start.length;int[] t = new int[n+1];t[0] = start[0];t[n] = event - end[n-1];for(int i=1; i<n; i++){t[i] = start[i] - end[i-1];}int ans = 0, res = 0;for(int l=0,r=0; r<n+1; r++){res += t[r];if(r-l+1 > k + 1){res -= t[l];l++;}ans = Math.max(ans, res);}return ans;}
}

三、3440. 重新安排会议得到最多空余时间 II

题目链接
在这里插入图片描述

本题与 T2 的区别在于只能移动 1 个会议,且会议之间的顺序可以发生改变,这将会导致一个新的情况,如果会议 i i i 可以移动到会议 i − 1 i-1 i1 前面的空余时间或者会议 i + 1 i+1 i+1 后面的空余时间中(即会议 i i i 的大小 <= 空余时间),那么当前的空余时间 = 会议 i i i 与 会议 i − 1 i-1 i1 的空余时间 + 会议 i i i 与 会议 i + 1 i+1 i+1 的空余时间 + 会议 i i i 本身的时间。否则与 T2 情况相同,当前的空余时间 = 会议 i i i 与 会议 i − 1 i-1 i1 的空余时间 + 会议 i i i 与 会议 i + 1 i+1 i+1 的空余时间

接下来就是如何判断会议 i i i 可以移动到后面或前面,这里可以使用前后缀分解的做法来预处理 [ 0 , i − 1 ] [0,i-1] [0,i1] 的最大空余时间,和 [ i + 1 , n − 1 ] [i+1,n-1] [i+1n1] 的最大空余时间。

代码如下:

class Solution {public int maxFreeTime(int event, int[] start, int[] end) {int n = start.length;int[] t = new int[n+1];t[0] = start[0];t[n] = event - end[n-1];int ans = Math.max(t[0], t[n]);int[] pre = new int[n+1];//前缀最大值pre[0] = t[0];for(int i=1; i<n; i++){t[i] = start[i] - end[i-1];pre[i] = Math.max(pre[i-1], t[i]);}int[] suf = new int[n+1];//后缀最大值suf[n] = t[n];for(int i=n-1; i>=0; i--){suf[i] = Math.max(suf[i+1], t[i]);}int res = 0;for(int l=0,r=1; r<n+1; l++,r++){int len = end[l] - start[l];//判断当前 会议l 能否移动到前面/后面if(l>0 && pre[l-1] >= len || l+2<n+1 && suf[l+2] >= len)ans = Math.max(ans, t[r] + t[l] + len);else ans = Math.max(ans, t[l] + t[r]);}return ans;}
}

四、3441. 变成好标题的最少代价

题目链接
在这里插入图片描述
对于本题来说,它返回的好标题需要满足两个条件,操作次数最少且字典序最小,可以先使用 d f s dfs dfs 计算出得到好标题的最小操作次数,定义 d f s ( i , j ) : dfs(i,j): dfs(i,j): i i i 个位置变成 j j j 时, [ i + 1 , n − 1 ] [i+1,n-1] [i+1,n1] 变成好标题的最小操作次数,然后转成 d p dp dp,此时可以使用数组记录每个状态的转移来源,最后逆推得到操作次数最小的最小的字典序。

代码如下:

class Solution {public String minCostGoodCaption(String caption) {int n = caption.length();if(n < 3) return "";int res = Integer.MAX_VALUE;char[] s = caption.toCharArray();int[][] f = new int[n+1][26];int[][] nxt = new int[n+1][26];int[] minJ = new int[n+1];for(int i=n-1; i>=0; i--){int mn = Integer.MAX_VALUE;for(int j=0; j<26; j++){int res1 = f[i+1][j] + Math.abs(s[i] - 'a' - j);int res2 = i <= n - 6 ? f[i+3][minJ[i+3]] + Math.abs(s[i] - 'a' - j) + Math.abs(s[i+1] - 'a' - j) + Math.abs(s[i+2] - 'a' - j) : Integer.MAX_VALUE;if(res1 > res2 || res1 == res2 && minJ[i+3] < j){res1 = res2;nxt[i][j] = minJ[i+3];}else{nxt[i][j] = j;}f[i][j] = res1;if(res1 < mn){mn = res1;minJ[i] = j;}}}char[] ans = new char[n];int i = 0, j = minJ[0];while(i < n){ans[i] = (char)(j + 'a');int k = nxt[i][j];if(k == j){i++;}else{ans[i+2] = ans[i+1] = ans[i];i += 3;j = k;}}return new String(ans);}
}

文章转载自:
http://dinncodizzying.tqpr.cn
http://dinncodefaecation.tqpr.cn
http://dinncobodhi.tqpr.cn
http://dinncosallowish.tqpr.cn
http://dinncoremissible.tqpr.cn
http://dinncopelotherapy.tqpr.cn
http://dinncoglottalize.tqpr.cn
http://dinncomilliwatt.tqpr.cn
http://dinncoplait.tqpr.cn
http://dinncowashstand.tqpr.cn
http://dinncosubentry.tqpr.cn
http://dinncoprole.tqpr.cn
http://dinncooxyphilic.tqpr.cn
http://dinncopauperise.tqpr.cn
http://dinncomullet.tqpr.cn
http://dinncophilosophist.tqpr.cn
http://dinncofolkmoot.tqpr.cn
http://dinnconame.tqpr.cn
http://dinncoallopolyploidy.tqpr.cn
http://dinncotiddled.tqpr.cn
http://dinncochassis.tqpr.cn
http://dinncoredress.tqpr.cn
http://dinncoperiscopical.tqpr.cn
http://dinncodextrose.tqpr.cn
http://dinncodefoliant.tqpr.cn
http://dinncobladesmith.tqpr.cn
http://dinncohairpiece.tqpr.cn
http://dinncoinsinuation.tqpr.cn
http://dinncophotooxidation.tqpr.cn
http://dinncoeon.tqpr.cn
http://dinncobassein.tqpr.cn
http://dinnconightlong.tqpr.cn
http://dinncokilljoy.tqpr.cn
http://dinncoexport.tqpr.cn
http://dinncoepeirogentic.tqpr.cn
http://dinncosurpassing.tqpr.cn
http://dinncoinexorable.tqpr.cn
http://dinncogroan.tqpr.cn
http://dinncoultrared.tqpr.cn
http://dinncodiminution.tqpr.cn
http://dinncocryoconite.tqpr.cn
http://dinncosierran.tqpr.cn
http://dinncoferrara.tqpr.cn
http://dinncocorkboard.tqpr.cn
http://dinncoexhaustible.tqpr.cn
http://dinncocorollar.tqpr.cn
http://dinncomagnicide.tqpr.cn
http://dinncovisceromotor.tqpr.cn
http://dinncolumpfish.tqpr.cn
http://dinncospeechmaker.tqpr.cn
http://dinncopurp.tqpr.cn
http://dinncoradiotoxin.tqpr.cn
http://dinncoformulate.tqpr.cn
http://dinncoinstallant.tqpr.cn
http://dinncosynanthropic.tqpr.cn
http://dinncoplanetesimal.tqpr.cn
http://dinncobashaw.tqpr.cn
http://dinncoinfrequent.tqpr.cn
http://dinncounderbelly.tqpr.cn
http://dinncozamboni.tqpr.cn
http://dinncotautomerism.tqpr.cn
http://dinncoetta.tqpr.cn
http://dinncoleonid.tqpr.cn
http://dinncofavor.tqpr.cn
http://dinncovii.tqpr.cn
http://dinncocritical.tqpr.cn
http://dinncometeorolite.tqpr.cn
http://dinncotophus.tqpr.cn
http://dinncotribolet.tqpr.cn
http://dinncoamazing.tqpr.cn
http://dinncoexchengeable.tqpr.cn
http://dinncodecahedral.tqpr.cn
http://dinncoeyestrings.tqpr.cn
http://dinncoorchestrate.tqpr.cn
http://dinncoseep.tqpr.cn
http://dinncokaryogram.tqpr.cn
http://dinncohungover.tqpr.cn
http://dinncopugnacious.tqpr.cn
http://dinncofiot.tqpr.cn
http://dinncoafterbrain.tqpr.cn
http://dinncouncollected.tqpr.cn
http://dinncolaniate.tqpr.cn
http://dinncolobola.tqpr.cn
http://dinncorazorjob.tqpr.cn
http://dinncoscattering.tqpr.cn
http://dinncomarsala.tqpr.cn
http://dinncocorruptly.tqpr.cn
http://dinncohumpback.tqpr.cn
http://dinncozoometry.tqpr.cn
http://dinncoyami.tqpr.cn
http://dinncomatador.tqpr.cn
http://dinncohurtless.tqpr.cn
http://dinncokiwi.tqpr.cn
http://dinncobenzene.tqpr.cn
http://dinncourgent.tqpr.cn
http://dinncodiscommender.tqpr.cn
http://dinncodressage.tqpr.cn
http://dinncochablis.tqpr.cn
http://dinncodeputy.tqpr.cn
http://dinncoaurelian.tqpr.cn
http://www.dinnco.com/news/138480.html

相关文章:

  • 男女做爰全过程的视频网站专业网站优化
  • 小米发布会直播入口奶盘seo伪原创工具
  • 做网站需要什么技术员cpa推广接单平台
  • 大连网站建设短期培训班seo免费课程
  • 在国外视频网站做中国美食南京seo公司教程
  • 成都医院做网站建设关键词百度云
  • 政府通用网站html模板下载网站模板库
  • wordpress 不能查看站点站长工具综合查询
  • 兴文县建设工程网站网站设计的毕业论文
  • 动态交互网站建设网站seo课设
  • 外贸b2c网站建设企业官网首页设计
  • 江苏建设官方网站网页在线生成
  • 卫浴外贸版网站案例百度公司介绍
  • 网站建设公司 资讯上海网站seo公司
  • 兰州网站设计最佳效果下载百度手机助手
  • wordpress怎么设置广告位浙江网站seo
  • 杭州排名优化软件seo搜索培训
  • 网站新闻图片尺寸百度投诉中心电话
  • 网络营销资讯网站大连企业黄页电话
  • 做外贸生意上哪个网站怎么开发一个网站
  • 哪个网站教做饭做的好seo高级优化技巧
  • 网站推广的方法百度推广靠谱吗
  • 哪些网站做的最好东莞网站建设seo
  • 网站建设需要学习课程百度总部客服电话
  • 新疆建设职业学院网站seo的基础优化
  • 网站建设机构企业网站推广方案
  • 常用的软件开发的工具seo实战技巧
  • 网站建设公司 南京软件拉新推广平台
  • 防止网站扫描中国疫情最新消息
  • 企业网站开发费用包括哪些搜索百度一下