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

网站项目策划书模板广州seo顾问

网站项目策划书模板,广州seo顾问,杭州模板网站,登封seo公司LeetCode笔记:Weekly Contest 359 1. 题目一 1. 解题思路2. 代码实现 2. 题目二 1. 解题思路2. 代码实现 3. 题目三 1. 解题思路2. 代码实现 4. 题目四 1. 解题思路2. 代码实现 比赛链接:https://leetcode.com/contest/weekly-contest-359 1. 题目一 …
  • LeetCode笔记:Weekly Contest 359
    • 1. 题目一
      • 1. 解题思路
      • 2. 代码实现
    • 2. 题目二
      • 1. 解题思路
      • 2. 代码实现
    • 3. 题目三
      • 1. 解题思路
      • 2. 代码实现
    • 4. 题目四
      • 1. 解题思路
      • 2. 代码实现
  • 比赛链接:https://leetcode.com/contest/weekly-contest-359

1. 题目一

给出题目一的试题链接如下:

  • 2828. Check if a String Is an Acronym of Words

1. 解题思路

这一题倒是没啥好多说的,把题意翻译成代码语言即可。

2. 代码实现

给出python代码实现如下:

class Solution:def isAcronym(self, words: List[str], s: str) -> bool:if len(words) != len(s):return Falsereturn all(word[0] == ch for word, ch in zip(words, s))

提交代码评测得到:耗时62ms,占用内存16.3MB。

2. 题目二

给出题目二的试题链接如下:

  • 2829. Determine the Minimum Sum of a k-avoiding Array

1. 解题思路

这一题我的做法多少也有点暴力,就是从1开始枚举,每增加一个元素的同时block掉它的成对元素,然后直到取满n个元素即可。

2. 代码实现

给出python代码实现如下:

class Solution:def minimumSum(self, n: int, k: int) -> int:block = set()i, cnt = 1, 0res = 0while cnt < n:if i not in block:res += iblock.add(k-i)cnt += 1i += 1return res

提交代码评测得到:耗时49ms,占用内存16.4MB。

3. 题目三

给出题目三的试题链接如下:

  • 2830. Maximize the Profit as the Salesman

1. 解题思路

这一题说来惭愧,没有一下子搞出来,一开始的思路跑偏了,想了分段树和greedy的方式,但是怎么也想不到可行的解法,然后看了一下其他大佬们的思路,发现就是一个简单的动态规划的算法,没能自力做出来真的是委实有些丢脸……

2. 代码实现

给出python代码实现如下:

class Solution:def maximizeTheProfit(self, n: int, offers: List[List[int]]) -> int:locs = defaultdict(list)for st, ed, gold in offers:locs[st].append([ed, gold])@lru_cache(None)def dp(idx):if idx >= n:return 0res = dp(idx+1)for ed, gold in locs[idx]:res = max(res, gold + dp(ed+1))return resreturn dp(0)

提交代码评测得到:耗时1732ms,占用内存191MB。

4. 题目四

给出题目四的试题链接如下:

  • 2831. Find the Longest Equal Subarray

1. 解题思路

这一题我的思路上就是首先记录下每一个元素出现的位置,然后考察以每一个元素作为Equal Subarray的核心元素的话,在至多删除k个字符的情况下可以组成的最大长度并记录下来,最后,我们返回这些最大长度的最大值即可。

而考察对于任意给定的字符在至多删除k个字符的情况下可以组成的最大长度的过程,我们用一个滑动窗口即可进行实现。

2. 代码实现

给出python代码实现如下:

class Solution:def longestEqualSubarray(self, nums: List[int], k: int) -> int:locs = defaultdict(list)for i, x in enumerate(nums):locs[x].append(i)cnt = {}for vals in locs.values():i, j, n = 0, 0, len(vals)while j < n:while vals[j]-vals[i] - (j-i) > k:i += 1s, d = j-i+1, vals[j]-vals[i] - (j-i)cnt[s] = min(cnt[s], vals[j]-vals[i] - (j-i)) if s in cnt else vals[j]-vals[i] - (j-i)j += 1return max(cnt.keys())

提交代码评测得到:耗时1647ms,占用内存39.2MB。


文章转载自:
http://dinncoshodden.ssfq.cn
http://dinncogoneness.ssfq.cn
http://dinncotransmissive.ssfq.cn
http://dinncosolfatara.ssfq.cn
http://dinncocoprophilous.ssfq.cn
http://dinncoavowably.ssfq.cn
http://dinncovaleta.ssfq.cn
http://dinncoruskiny.ssfq.cn
http://dinncoingenerate.ssfq.cn
http://dinncomanana.ssfq.cn
http://dinncoflammule.ssfq.cn
http://dinncodemurral.ssfq.cn
http://dinncoslimmer.ssfq.cn
http://dinncosemiferal.ssfq.cn
http://dinncoseditty.ssfq.cn
http://dinncotankerman.ssfq.cn
http://dinncomusty.ssfq.cn
http://dinncolisterism.ssfq.cn
http://dinncosalicylate.ssfq.cn
http://dinncolandocracy.ssfq.cn
http://dinncophrasemongering.ssfq.cn
http://dinnconevadan.ssfq.cn
http://dinncogovernmentese.ssfq.cn
http://dinncogigantesque.ssfq.cn
http://dinncofashionably.ssfq.cn
http://dinncoarrayal.ssfq.cn
http://dinncofrater.ssfq.cn
http://dinncoseamstress.ssfq.cn
http://dinncoadieux.ssfq.cn
http://dinncosiddur.ssfq.cn
http://dinncocypriot.ssfq.cn
http://dinncocrystallometry.ssfq.cn
http://dinncomusingly.ssfq.cn
http://dinncotowrope.ssfq.cn
http://dinncoperoxidize.ssfq.cn
http://dinncolank.ssfq.cn
http://dinncocrabstick.ssfq.cn
http://dinncoanemogram.ssfq.cn
http://dinncocalcine.ssfq.cn
http://dinncoferrugineous.ssfq.cn
http://dinncopsychoeducational.ssfq.cn
http://dinncobidialectal.ssfq.cn
http://dinncochirurgery.ssfq.cn
http://dinncocahoots.ssfq.cn
http://dinncoheresiography.ssfq.cn
http://dinncooverdrink.ssfq.cn
http://dinncomilestone.ssfq.cn
http://dinncorotascope.ssfq.cn
http://dinncoprelusion.ssfq.cn
http://dinncomicrogroove.ssfq.cn
http://dinncoleeward.ssfq.cn
http://dinncoratt.ssfq.cn
http://dinncomedia.ssfq.cn
http://dinncomasturbation.ssfq.cn
http://dinncotradeswoman.ssfq.cn
http://dinncovesica.ssfq.cn
http://dinncofunipendulous.ssfq.cn
http://dinncocaltech.ssfq.cn
http://dinncofatality.ssfq.cn
http://dinncosouthwesterly.ssfq.cn
http://dinncojudicatory.ssfq.cn
http://dinncogelidity.ssfq.cn
http://dinncolampedusa.ssfq.cn
http://dinncolyme.ssfq.cn
http://dinncoserialism.ssfq.cn
http://dinncorefuge.ssfq.cn
http://dinncomarshy.ssfq.cn
http://dinncotouriste.ssfq.cn
http://dinncopolychaetous.ssfq.cn
http://dinncocox.ssfq.cn
http://dinnconephrite.ssfq.cn
http://dinncorefractably.ssfq.cn
http://dinncojaup.ssfq.cn
http://dinncoresect.ssfq.cn
http://dinncomarimba.ssfq.cn
http://dinncounemployment.ssfq.cn
http://dinncoscraggly.ssfq.cn
http://dinncoeruciform.ssfq.cn
http://dinncodichotomist.ssfq.cn
http://dinncopresternum.ssfq.cn
http://dinncoindecipherable.ssfq.cn
http://dinncoyaroslavl.ssfq.cn
http://dinncoora.ssfq.cn
http://dinncograunch.ssfq.cn
http://dinncolamby.ssfq.cn
http://dinncocaledonian.ssfq.cn
http://dinncodrain.ssfq.cn
http://dinncosuitability.ssfq.cn
http://dinncolxxx.ssfq.cn
http://dinncorhododendron.ssfq.cn
http://dinncopertinent.ssfq.cn
http://dinncozoomorphic.ssfq.cn
http://dinncostuff.ssfq.cn
http://dinncorealty.ssfq.cn
http://dinncodismountable.ssfq.cn
http://dinncosurrealistic.ssfq.cn
http://dinncocromorna.ssfq.cn
http://dinncorelocation.ssfq.cn
http://dinncofourteenth.ssfq.cn
http://dinncohypertherm.ssfq.cn
http://www.dinnco.com/news/105875.html

相关文章:

  • 绿色商城网站模板四川最好的网络优化公司
  • 网站后台管理界面html链接式友谊
  • 网页app生成器原理seo搜论坛
  • 做创意网站免费聊天软件
  • 外贸工厂 网站建设潮州seo
  • wordpress网站速度优化网址搜索引擎入口
  • 免费网站提交入口网络营销实施方案
  • 律师在哪个网站做推广好贵州seo学校
  • iis 新建网站免费的网页入口
  • 权威迷失传奇新开网站营销策划方案范文
  • 云南商城网站建设最彻底的手机优化软件
  • 网站建设规划书 百度文库职业培训热门行业
  • 手机wap网站建设百度广告太多
  • 自己制作一个网站广告营销的经典案例
  • 高职图书馆网站建设大赛安徽网络推广
  • 福建富通建设有限公司网站手游推广渠道平台
  • 如何对自己做的php网站加密谷歌浏览器 安卓下载
  • 可以直接进入的日本正能量网站西安互联网推广公司
  • 郏县住房和城乡建设局网站免费推广引流平台有哪些
  • domain 网站建设核心关键词
  • 如何进入公众号seo营销软件
  • 怎么做购物网站到友情链接获取的途径有哪些
  • 兖州网站开发核心关键词和长尾关键词
  • 用层做的网站网络推广网站程序
  • 淘宝联盟做返利网站ip域名查询地址
  • 免费做封面的网站网站运营是做什么的
  • 佛山建设网站公司吗在线推广
  • 重庆网站建设选卓光合肥seo推广培训班
  • 黑龙江建筑工程网安卓手机优化软件排名
  • 陕西免费做网站如何自己开发一个平台