随笔分类 -  查找算法

摘要:题目链接:https://leetcode-cn.com/problems/search-a-2d-matrix 题目描述: 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性: 每行中的整数从左到右按升序排列。 每行的第一个整数大于前一行的最后一个整数。 示例 1 阅读全文
posted @ 2021-11-19 11:24 张宵 阅读(20) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/search-in-rotated-sorted-array 题目描述:整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 ⇐ k < nums.length) 阅读全文
posted @ 2021-11-19 11:21 张宵 阅读(27) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array 题目描述: 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位 阅读全文
posted @ 2021-11-19 11:20 张宵 阅读(32) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/search-in-rotated-sorted-array 题目描述: 整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 ⇐ k < nums.length 阅读全文
posted @ 2021-04-07 22:23 张宵 阅读(62) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/search-insert-position 题目描述: 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 你可以假设数组中无重复元素。 示例 1: 输 阅读全文
posted @ 2021-01-17 14:42 张宵 阅读(50) 评论(0) 推荐(0)