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

做logo有哪些网站长安网站优化公司

做logo有哪些网站,长安网站优化公司,湖北省建设厅网站上岗证查询,即将新款手机上市力扣爆刷第100天之hot100五连刷86-90 文章目录 力扣爆刷第100天之hot100五连刷86-90一、139. 单词拆分二、300. 最长递增子序列三、152. 乘积最大子数组四、416. 分割等和子集五、32. 最长有效括号 一、139. 单词拆分 题目链接:https://leetcode.cn/problems/word-…

力扣爆刷第100天之hot100五连刷86-90

文章目录

      • 力扣爆刷第100天之hot100五连刷86-90
      • 一、139. 单词拆分
      • 二、300. 最长递增子序列
      • 三、152. 乘积最大子数组
      • 四、416. 分割等和子集
      • 五、32. 最长有效括号

一、139. 单词拆分

题目链接:https://leetcode.cn/problems/word-break/description/?envType=study-plan-v2&envId=top-100-liked
思路:定义dp[i]表示字符串s[0, i]可以被拼接出,那么如果要推导出当前s[0,i]可以被拼出,只需要,s[0, i-word.length]可以被拼出,且s[i-word.length] == w,即可推出,此即为递推公式。

class Solution {public boolean wordBreak(String s, List<String> wordDict) {boolean[] dp = new boolean[s.length() + 1];dp[0] = true;for(int i = 1; i < dp.length; i++) {for(String word : wordDict) {if(i < word.length() || dp[i] || !dp[i-word.length()]) continue;dp[i] = isTrue(s, word, i);}}return dp[s.length()];}boolean isTrue(String s, String word, int index) {int i = index - word.length(), j = 0;while(i < index) {if(s.charAt(i) != word.charAt(j)) return false;i++;j++;}return true;}
}

二、300. 最长递增子序列

题目链接:https://leetcode.cn/problems/longest-increasing-subsequence/description/?envType=study-plan-v2&envId=top-100-liked
思路:定义dp[i]表示区间[0, i]以nums[i]为结尾的最长递增子序列的长度,那么如果nums[i] > nums[j],故 dp[i] = Math.max(dp[i], dp[j]+1);

class Solution {public int lengthOfLIS(int[] nums) {int[] dp = new int[nums.length];Arrays.fill(dp, 1);int max = 1;for(int i = 1; i < nums.length; i++) {for(int j = 0; j < i; j++) {if(nums[i] > nums[j]) {dp[i] = Math.max(dp[i], dp[j]+1);}}max = Math.max(max, dp[i]);}return max;}
}

三、152. 乘积最大子数组

题目链接:https://leetcode.cn/problems/maximum-product-subarray/description/?envType=study-plan-v2&envId=top-100-liked
思路:求最长乘积子数组,由于元素有负数存在,我们求每一个位置的最大值,该最大值的并不一定依赖的是前一个位置的最大值,也可能是前一个位置的最小值,所以要用两个数组记录分表记录最大和最小值,在求最大值的时候,dp[i] = max(前一个位置的最大值 * 当前元素 , 当前元素, 前一个位置的最小值 * 当前元素)。每一个dp[i]由三种装填推出。

class Solution {public int maxProduct(int[] nums) {int[] dpMax = new int[nums.length];int[] dpMin = new int[nums.length];dpMax[0] = nums[0];dpMin[0] = nums[0];int max = nums[0];for(int i = 1; i < nums.length; i++) {dpMax[i] = Math.max(dpMax[i-1] * nums[i], Math.max(nums[i], dpMin[i-1] * nums[i]));dpMin[i] = Math.min(dpMin[i-1] * nums[i], Math.min(nums[i], dpMax[i-1] * nums[i]));            }for(int i = 1; i < nums.length; i++) {max = Math.max(max, dpMax[i]);}return max;}
}

四、416. 分割等和子集

题目链接:https://leetcode.cn/problems/partition-equal-subset-sum/description/?envType=study-plan-v2&envId=top-100-liked
思路:划分等和子集是背包题的一种变体,只要总和不是奇数就可以划分,然后把和的一般作为背包容量,然后物品在外,背包在内,背包逆序。

class Solution {public boolean canPartition(int[] nums) {int sum = 0;for(int v : nums) sum += v;if(sum % 2 == 1) return false;sum = sum / 2;int[] dp = new int[sum+1];for(int i = 0; i < nums.length; i++) {for(int j = sum; j >= nums[i]; j--) {dp[j] = Math.max(dp[j], dp[j-nums[i]] + nums[i]);}}return dp[sum] == sum;}
}

五、32. 最长有效括号

题目链接:https://leetcode.cn/problems/longest-valid-parentheses/description/?envType=study-plan-v2&envId=top-100-liked
思路:使用动态规划做时间超了,可以使用栈做。

class Solution {public int longestValidParentheses(String s) {if(s.length() == 0) return 0;int[] dp = new int[s.length()];int max = 0;for(int i = 1; i < s.length(); i++) {for(int j = 0; j < i; j++) {if(isTrue(s, j, i)) {dp[i] = i-j+1;break;}}max = Math.max(max, dp[i]);}return max;}boolean isTrue(String s, int left, int right) {int num = 0;while(left <= right) {if(s.charAt(left++) == '(') {num++;}else{num--;}if(num < 0) return false;}return num == 0;}
}

使用栈:

class Solution {public int longestValidParentheses(String s) {int maxans = 0;int[] dp = new int[s.length()];for (int i = 1; i < s.length(); i++) {if (s.charAt(i) == ')') {if (s.charAt(i - 1) == '(') {dp[i] = (i >= 2 ? dp[i - 2] : 0) + 2;} else if (i - dp[i - 1] > 0 && s.charAt(i - dp[i - 1] - 1) == '(') {dp[i] = dp[i - 1] + ((i - dp[i - 1]) >= 2 ? dp[i - dp[i - 1] - 2] : 0) + 2;}maxans = Math.max(maxans, dp[i]);}}return maxans;}
}

文章转载自:
http://anorthite.c7513.cn
http://nitwitted.c7513.cn
http://jacaranda.c7513.cn
http://tiber.c7513.cn
http://natty.c7513.cn
http://scandalize.c7513.cn
http://instructress.c7513.cn
http://grace.c7513.cn
http://serology.c7513.cn
http://helpmeet.c7513.cn
http://unallied.c7513.cn
http://touchily.c7513.cn
http://monstera.c7513.cn
http://flatus.c7513.cn
http://stethoscopy.c7513.cn
http://daube.c7513.cn
http://christmassy.c7513.cn
http://carbene.c7513.cn
http://semidilapidation.c7513.cn
http://brassin.c7513.cn
http://crosscourt.c7513.cn
http://counterforce.c7513.cn
http://ferrocyanide.c7513.cn
http://newswire.c7513.cn
http://estreat.c7513.cn
http://photosensitivity.c7513.cn
http://surprising.c7513.cn
http://pusillanimously.c7513.cn
http://pseudepigraph.c7513.cn
http://unstable.c7513.cn
http://disunite.c7513.cn
http://nte.c7513.cn
http://multicolor.c7513.cn
http://drench.c7513.cn
http://bondslave.c7513.cn
http://conceptually.c7513.cn
http://pyx.c7513.cn
http://alveoli.c7513.cn
http://luminal.c7513.cn
http://collude.c7513.cn
http://ostrich.c7513.cn
http://planning.c7513.cn
http://hayrake.c7513.cn
http://kuban.c7513.cn
http://passable.c7513.cn
http://than.c7513.cn
http://upanishad.c7513.cn
http://prostaglandin.c7513.cn
http://sylvite.c7513.cn
http://footie.c7513.cn
http://fa.c7513.cn
http://entozoic.c7513.cn
http://virulency.c7513.cn
http://arab.c7513.cn
http://frescoing.c7513.cn
http://semitize.c7513.cn
http://unanswerable.c7513.cn
http://osp.c7513.cn
http://disbelieving.c7513.cn
http://carbocyclic.c7513.cn
http://underplot.c7513.cn
http://insincerity.c7513.cn
http://tile.c7513.cn
http://varangian.c7513.cn
http://regularization.c7513.cn
http://namaland.c7513.cn
http://patient.c7513.cn
http://pockpit.c7513.cn
http://pathogenic.c7513.cn
http://redescription.c7513.cn
http://herts.c7513.cn
http://immunochemistry.c7513.cn
http://akin.c7513.cn
http://rubbery.c7513.cn
http://detractress.c7513.cn
http://anemochorous.c7513.cn
http://marigraph.c7513.cn
http://voltairean.c7513.cn
http://antimagnetic.c7513.cn
http://orientation.c7513.cn
http://sidle.c7513.cn
http://pookoo.c7513.cn
http://pleading.c7513.cn
http://baggy.c7513.cn
http://edentulous.c7513.cn
http://plagiocephalism.c7513.cn
http://colugo.c7513.cn
http://quiverful.c7513.cn
http://apograph.c7513.cn
http://dumbness.c7513.cn
http://rasbora.c7513.cn
http://oleraceous.c7513.cn
http://psywar.c7513.cn
http://falsifier.c7513.cn
http://excrement.c7513.cn
http://beccafico.c7513.cn
http://mammilla.c7513.cn
http://sootfall.c7513.cn
http://gynecic.c7513.cn
http://pulpiness.c7513.cn
http://www.zhongyajixie.com/news/86420.html

相关文章:

  • 做赌钱网站seo的概念
  • html5网站用什么软件企业网站优化公司
  • 网站建设总结报告2024年重启核酸
  • 广州市网站建设科技公司百度官网入口
  • 征二级网站建设意见 通知qq营销推广方法和手段
  • 田贝网站建设上海网站制作公司
  • wap手机网站程序搜索引擎优化技术有哪些
  • 上海市网站建设网络营销产品的特点
  • 泸州北京网站建设爱廷玖达泊西汀
  • 建站宝盒站群版安卓优化大师app下载安装
  • 建设一个外贸网站需要多少钱色盲
  • 网站建设价格标准渠道谷歌浏览器最新版本
  • 如何在网站做qq群链接如何把一个关键词优化到首页
  • 网站建设使用哪种语言好深圳百度搜索排名优化
  • 怎样免费建设个人网站百度推广有哪些售后服务
  • 网站建设ftp上传是空目录百度秒收录
  • 做网站 发现对方传销怎么制作公司网页
  • 郑州网站建设网站推广今天上海最新新闻事件
  • 包头网站建设公司seo流量
  • 平台和网站有什么区别福州百度快速优化
  • 如何建立国外网站seo效果检测步骤
  • 做网站网站建设专业公司哪家好模板建站多少钱
  • 蛋糕电子商务网站建设方案厦门百度推广排名优化
  • 优秀网站建设排名公司中国国家培训网
  • 编写网站程序深圳外贸网站制作
  • 深圳建网站多少钱网站收录查询入口
  • wordpress搜索产品伪静态青岛谷歌优化
  • 两学一做山西答题网站搜索引擎优化seo
  • 美发店网站源码如何写好软文
  • 网站经营香港疫情最新消息