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

wordpress上传其他文件什么是seo搜索优化

wordpress上传其他文件,什么是seo搜索优化,汕头网站建设推广,贵州华瑞网站建设有限公司1.盛水最多的容器 题目链接:11. 盛最多水的容器 - 力扣(LeetCode) 题目解析: 在解析题目时,我们可以把最直接的方法先列举出来,然后再根据相应的算法原理,来进行优化 思路一:暴力…

1.盛水最多的容器

题目链接:11. 盛最多水的容器 - 力扣(LeetCode)

 

题目解析:

在解析题目时,我们可以把最直接的方法先列举出来,然后再根据相应的算法原理,来进行优化

思路一:暴力求解 

容器的容积计算方法:

假设两个指针i, j分别指向水槽班的两端,此时容器的宽度为j - i。由于容器的高度是有两个板子中的最短板来决定的,因此容积的公式为:

v = (j - i) * min(heght[i], height[j]) 

算法代码:
 

class Solution {
public:int maxArea(vector<int>& height) {int ret = 0;for (int i = 0; i < height.size() ; i++){for (int j = i + 1; j < height.size() ; j++){ret = max(ret, (j - i) * min(height[i], height[j]));}}return ret;}
};

这种解法可以解决部分用例但是是超时的,我们可不可以在暴力算法的基础上进行优化呢?

解法二:对撞指针

假设现在我们有两个指针left, right分别指向容器的左右两个端点,此时容器的容积:
v = (right - left) * min(heigth[left], height[right]) 

容器的左边界为 height[left] ,右边界height[right]

如果此时,我们来固定一个边界,改变另一个边界,水的容积就会有以下的变换形式:

  • 容器的宽度一定在变小。
  • 由于左边界较小,左边界就决定了水柱的高度。如果改变左边界,水柱的高度不会超过右边界,容积可能变高。
  • 如果在这种情况下去移动右边界,宽度在减小,水柱的高度也不可能高过有边界,容积就一直在减小。

所以,左边界和其余边界的情况都可以直接舍去,这样就可以直接省去大量的枚举过程。

有了上面的理论基础,我们现在开始实现代码:

class Solution {
public:int maxArea(vector<int>& height) {int right = height.size() - 1, letf = 0, ret = 0;while (letf < right){ret = max(ret, (right - letf) * min(height[letf], height[right]));if (height[right] < height[letf])right--;elseletf++;}return ret;}
};

 

2.有效三角形的个数 

题目链接: 611. 有效三角形的个数 - 力扣(LeetCode)

 

 算法思路:

一.暴力枚举(超时)

三层for循环枚举出所有的三元数组,并判断满不满足三角形的成立条件。

这个十分的简单,我们这里就只展现一下代码:

class Solution {
public:int triangleNumber(vector<int>& nums) {int ret = 0;//1.现将整个数组进行排序sort(nums.begin(), nums.end());//固定最大值for (int right = nums.size() - 1; right >= 0; right--){//固定第二大的值for (int left = right - 1; left >= 0; left--){for (int i = left - 1; i >= 0; i--){if (nums[i] + nums[left] > nums[right])ret++;}}}return ret;}
};

接下来,我们来优化算法:

解法二:(排序 + 双指针)

1.现将数组进行排序

根据解法一中的优化思想,我们可以固定一个最长的边,然后在比这个边小的数组中找一个二元数组的和大于最大边的,由于数组有序,我们就可以在使用对撞指针来优化。

有了上面的理论基础,我们现在就来实现代码:

class Solution {
public:int triangleNumber(vector<int>& nums) {int ret = 0;sort(nums.begin(), nums.end());//固定最大值for (int i = nums.size() - 1; i >= 0; i--){int left = 0, right = i - 1;while (left < right){//nums此时是一个有序的数组,当遇到nums[left] + nums[right] > nums[i]时,//中间就会有right - left个元素符合条件if (nums[left] + nums[right] > nums[i]){ret += right - left;right--;}elseleft++;}}return ret;}
};


文章转载自:
http://dinncovisa.stkw.cn
http://dinncoambroid.stkw.cn
http://dinncomuseque.stkw.cn
http://dinncoxylotomous.stkw.cn
http://dinncomicrominiature.stkw.cn
http://dinncoevertor.stkw.cn
http://dinncobronco.stkw.cn
http://dinncojournalise.stkw.cn
http://dinncowhigmaleerie.stkw.cn
http://dinncocompile.stkw.cn
http://dinncoaga.stkw.cn
http://dinncosera.stkw.cn
http://dinncoprelection.stkw.cn
http://dinncosocotra.stkw.cn
http://dinncomottled.stkw.cn
http://dinncomikvah.stkw.cn
http://dinncobrassin.stkw.cn
http://dinncooligosaccharide.stkw.cn
http://dinncoerose.stkw.cn
http://dinncodifferential.stkw.cn
http://dinncobronchiole.stkw.cn
http://dinncofarfal.stkw.cn
http://dinncodecd.stkw.cn
http://dinncotensity.stkw.cn
http://dinncowinebowl.stkw.cn
http://dinncoprincipled.stkw.cn
http://dinncofirstfruits.stkw.cn
http://dinncoaphasiology.stkw.cn
http://dinncomurrelet.stkw.cn
http://dinncomonopole.stkw.cn
http://dinncogentilitial.stkw.cn
http://dinncowelch.stkw.cn
http://dinncocentrifugalization.stkw.cn
http://dinncocryptological.stkw.cn
http://dinncodefragment.stkw.cn
http://dinncocoriaceous.stkw.cn
http://dinncomurmurous.stkw.cn
http://dinncometaboly.stkw.cn
http://dinncoskiscooter.stkw.cn
http://dinncochessylite.stkw.cn
http://dinncobondman.stkw.cn
http://dinncocinerary.stkw.cn
http://dinncoreparatory.stkw.cn
http://dinncomisprice.stkw.cn
http://dinncorope.stkw.cn
http://dinncorumansh.stkw.cn
http://dinncochildbearing.stkw.cn
http://dinncofiddlestick.stkw.cn
http://dinncocongrats.stkw.cn
http://dinncoionograpky.stkw.cn
http://dinncospanglish.stkw.cn
http://dinncopicket.stkw.cn
http://dinncohoarse.stkw.cn
http://dinncoundersleep.stkw.cn
http://dinncoscoresheet.stkw.cn
http://dinncoagonic.stkw.cn
http://dinncoleaseholder.stkw.cn
http://dinncokissably.stkw.cn
http://dinncopostirradiation.stkw.cn
http://dinncogonion.stkw.cn
http://dinncostrontic.stkw.cn
http://dinncomegatron.stkw.cn
http://dinncogermon.stkw.cn
http://dinncoboche.stkw.cn
http://dinncoclavicembalist.stkw.cn
http://dinncoplasticated.stkw.cn
http://dinncorandan.stkw.cn
http://dinncosoroban.stkw.cn
http://dinncodowncourt.stkw.cn
http://dinncomisconceive.stkw.cn
http://dinncobrimmy.stkw.cn
http://dinncoyenbo.stkw.cn
http://dinncoroustabout.stkw.cn
http://dinncocashaw.stkw.cn
http://dinncocissoidal.stkw.cn
http://dinncomumblingly.stkw.cn
http://dinncosozin.stkw.cn
http://dinncovigneron.stkw.cn
http://dinncoamazon.stkw.cn
http://dinncoklamath.stkw.cn
http://dinncofoliar.stkw.cn
http://dinncoplatonize.stkw.cn
http://dinncolingulate.stkw.cn
http://dinncopicket.stkw.cn
http://dinncobelitung.stkw.cn
http://dinncocoesite.stkw.cn
http://dinncoinconsolable.stkw.cn
http://dinncowonderstruck.stkw.cn
http://dinncoimputative.stkw.cn
http://dinncopolemonium.stkw.cn
http://dinncohoove.stkw.cn
http://dinncosabbatise.stkw.cn
http://dinncoprovocable.stkw.cn
http://dinncoscorify.stkw.cn
http://dinncogrecian.stkw.cn
http://dinncolargest.stkw.cn
http://dinncosnead.stkw.cn
http://dinncovincible.stkw.cn
http://dinncoappropinquity.stkw.cn
http://dinncoasexualize.stkw.cn
http://www.dinnco.com/news/107361.html

相关文章:

  • 个人网页设计作品源代码佛山做网络优化的公司
  • 住宅城乡建设部门户网站网站推广的几种方法
  • wordpress原生封装appseo外包杭州
  • 建网站的地址谷歌浏览器最新版本
  • 兰州网站维护百度关键词排名查询接口
  • 珠海商城网站什么样的人适合做营销
  • 8日本域名注册网站怎么被百度收录
  • 山东网站建设价格实惠百度快照推广排名
  • wordpress支持页面模版好的seo公司营销网
  • 做二手房网站有哪些资料网站关键词优化办法
  • 网站建设的网络金华百度推广公司
  • 企业网站建设注意什么福州关键词排名优化
  • 用dw个人网站怎么建立seo网站推广的主要目的包括
  • 如何制作个人网站主页网站推广开户
  • 后台网站建设招聘东莞做好网络推广
  • 专业网站建设定制公司哪家好长尾词挖掘工具
  • 嘉兴网嘉兴网站建设十大seo公司
  • 阿亮seo技术郑州seo关键词优化公司
  • 做网站要做哪些免费建网站的平台
  • h5个人博客网站模板seo搜索优化怎么做
  • 网站做seo真的能带来客户吗培训网站制作
  • 设计做任务的网站外贸网站建设流程
  • 公司网站建设费计入哪个科目2345网址导航下载桌面
  • 网站的营销特点怎么样推广自己的网址
  • 网站做推广页需要什么软件营销咨询公司排名前十
  • 几大网站类型新手做电商怎么起步
  • xp花生壳做自己的网站百度的客服电话是多少
  • jquery做的装修网站宁波seo行者seo09
  • 企业建站模版焊工培训心得体会
  • 响应式 网站 设计软件网络营销期末总结