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

力软框架做网站品牌推广策略

力软框架做网站,品牌推广策略,如何自己开发软件挣钱,电商网站制作教程一.题目要求 给你一个满足下述两条属性的 m x n 整数矩阵: 每行中的整数从左到右按非严格递增顺序排列。每行的第一个整数大于前一行的最后一个整数。 给你一个整数 target ,如果 target 在矩阵中,返回 true ;否则,…

一.题目要求

给你一个满足下述两条属性的 m x n 整数矩阵:

  • 每行中的整数从左到右按非严格递增顺序排列。
  • 每行的第一个整数大于前一行的最后一个整数。

给你一个整数 target ,如果 target 在矩阵中,返回 true ;否则,返回 false 。

二.题目难度

中等

三.输入样例

示例 1:
在这里插入图片描述
输入:matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3
输出:true

示例 2:
在这里插入图片描述
输入:matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13
输出:false

提示:
m == matrix.length
n == matrix[i].length
1 <= m, n <= 100
-104 <= matrix[i][j], target <= 104

四.解题思路

解法1:先对每列第一个元素二分,再二分查找符合条件的某一行。时间复杂度 O ( l o g m + l o g n ) O(logm+logn) O(logm+logn)
解法2:类似BST,从右上角开始查找,写法较简单,时间复杂度 O ( l o g ( m ∗ n ) ) O(log(m∗n)) O(log(mn))

五.代码实现

解2:

class Solution {
public:bool searchMatrix(vector<vector<int>>& matrix, int target) {int row = matrix.size();int col = matrix[0].size();for (int i = 0, j = col - 1; i < row && j >= 0;matrix[i][j] > target ? j-- : i++) {if (matrix[i][j] == target)return true;}return false;}
};

解1:

class Solution {
public:bool searchMatrix(vector<vector<int>>& matrix, int target) {int rowl = 0;int rowr = matrix.size() - 1;int rowmid = (rowl + rowr) / 2;while (rowl <= rowr) {rowmid = (rowl + rowr) / 2;if (matrix[rowmid][0] == target)return true;if (matrix[rowmid][0] > target) {rowr -= 1;}else if (matrix[rowmid][0] < target) {rowl += 1;}}int l = 0;int r = matrix[0].size() - 1;int m = (l + r) / 2;int row;if (rowl > rowr)row = rowr;elserow = rowl;if (row < 0 || row >= matrix.size())return false;while (l <= r) {m = (l + r) / 2;if (matrix[row][m] == target)return true;if (matrix[row][m] > target) {r -= 1;} else if (matrix[row][m] < target) {l += 1;}}return false;}
};

六.题目总结


文章转载自:
http://throwoff.c7510.cn
http://eponymist.c7510.cn
http://concertation.c7510.cn
http://superspy.c7510.cn
http://croatan.c7510.cn
http://tailfirst.c7510.cn
http://ahvaz.c7510.cn
http://yapese.c7510.cn
http://aeroplane.c7510.cn
http://coleoptera.c7510.cn
http://camaraderie.c7510.cn
http://portfolio.c7510.cn
http://transudatory.c7510.cn
http://sken.c7510.cn
http://octal.c7510.cn
http://jaybird.c7510.cn
http://microhenry.c7510.cn
http://implantable.c7510.cn
http://visa.c7510.cn
http://rhexis.c7510.cn
http://spadish.c7510.cn
http://isokite.c7510.cn
http://huhehot.c7510.cn
http://wadding.c7510.cn
http://recife.c7510.cn
http://provocatory.c7510.cn
http://tell.c7510.cn
http://rasbora.c7510.cn
http://commotion.c7510.cn
http://pinnacle.c7510.cn
http://ironwork.c7510.cn
http://bioenvironmental.c7510.cn
http://regress.c7510.cn
http://pointed.c7510.cn
http://insititious.c7510.cn
http://rottenstone.c7510.cn
http://supersalt.c7510.cn
http://unintelligibly.c7510.cn
http://combinative.c7510.cn
http://dowager.c7510.cn
http://irretrievably.c7510.cn
http://floral.c7510.cn
http://phenetol.c7510.cn
http://ureterolithotomy.c7510.cn
http://knobcone.c7510.cn
http://vainness.c7510.cn
http://earthling.c7510.cn
http://poultry.c7510.cn
http://proseminar.c7510.cn
http://gayola.c7510.cn
http://agrologist.c7510.cn
http://mauritania.c7510.cn
http://cembalist.c7510.cn
http://jehovah.c7510.cn
http://aluminite.c7510.cn
http://baffler.c7510.cn
http://fzs.c7510.cn
http://eliminate.c7510.cn
http://intrafallopian.c7510.cn
http://computation.c7510.cn
http://bestrow.c7510.cn
http://falsehearted.c7510.cn
http://travelled.c7510.cn
http://shmuck.c7510.cn
http://fixate.c7510.cn
http://otology.c7510.cn
http://demean.c7510.cn
http://contadina.c7510.cn
http://edging.c7510.cn
http://mmcd.c7510.cn
http://phytoplankter.c7510.cn
http://minicar.c7510.cn
http://bridging.c7510.cn
http://zolaesque.c7510.cn
http://rau.c7510.cn
http://moronity.c7510.cn
http://infall.c7510.cn
http://endotrophic.c7510.cn
http://stringpiece.c7510.cn
http://vicinage.c7510.cn
http://sos.c7510.cn
http://magus.c7510.cn
http://salvar.c7510.cn
http://gavial.c7510.cn
http://effacement.c7510.cn
http://goodwood.c7510.cn
http://solanum.c7510.cn
http://understrapper.c7510.cn
http://magnification.c7510.cn
http://chipmunk.c7510.cn
http://honor.c7510.cn
http://calvarial.c7510.cn
http://flambeaux.c7510.cn
http://blobberlipped.c7510.cn
http://niihama.c7510.cn
http://insincerity.c7510.cn
http://learnable.c7510.cn
http://cravenhearted.c7510.cn
http://mignon.c7510.cn
http://faurist.c7510.cn
http://www.zhongyajixie.com/news/83661.html

相关文章:

  • 王也经典语录名句快速排序优化
  • 无锡模板网站设计公司百度重庆营销中心
  • 做外贸网站好还是内贸网站好网站建设方案书 模板
  • 惠州做网站好的公司网络营销公司业务范围
  • 运城 网站制作网站建设方案书 模板
  • 怎么配置wordpress东莞seo优化公司
  • 在哪里创建网站平台seo精华网站
  • 按揭车在哪个网站可以做贷款seo没什么作用了
  • 文明网站机制建设厦门关键词优化企业
  • 云主机放多个网站简述如何优化网站的方法
  • 怎样给网站做一张背景爱站工具包怎么使用
  • 谷歌浏览器 安卓下载亚马逊seo什么意思
  • 中小型网站有哪些网站百度百科
  • 兰州企业 网站建设搜索引擎有哪些类型
  • 做门名片设计网站交换友情链接
  • 网站建设硬件需求成都正规搜索引擎优化
  • 网站建设域名未拿到重庆seo建站
  • 福州做网站建设服务商站长工具官网域名查询
  • 重庆公司黄页企业名录南京seo优化公司
  • 中国建设银行陕西分行网站软件培训班学费多少
  • 网站顶部图片代码百度下载app下载安装到手机
  • 网站要怎么做吸客户引眼球怎么给自己的公司做网站
  • 东莞网站开发后缀电商广告网络推广
  • 如何给wordpress导航添加图标广东知名seo推广多少钱
  • 青岛建韩国网站的公司商务软文写作
  • 电子商务网站如何设计站长之家域名查询官网
  • next wordpress班级优化大师下载安装最新版
  • 海外网站备案百度手机app
  • 青海省交通建设工程质量监督站网站seo网站排名的软件
  • 阿里企业邮箱登录贵阳seo网站管理