
LeetCode
https://leetcode-cn.com/
IT_Kyle
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode-35. 搜索插入位置
题目描述: 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 你可以假设数组中无重复元素。 class Solution { public: int searchInsert(vector<int>& nums, int target) { int nLeft = 0; int nRight = nums.size() - 1; int nMid =原创 2021-07-15 14:43:21 · 158 阅读 · 0 评论 -
LeetCode-278. 第一个错误的版本
问题描述: 你是产品经理,目前正在带领一个团队开发新的产品。不幸的是,你的产品的最新版本没有通过质量检测。由于每个版本都是基于之前的版本开发的,所以错误的版本之后的所有版本都是错的。 假设你有 n 个版本 [1, 2, ..., n],你想找出导致之后所有版本出错的第一个错误的版本。 你可以通过调用bool isBadVersion(version)接口来判断版本号 version 是否在单元测试中出错。实现一个函数来查找第一个错误的版本。你应该尽量减少对调用 API 的次数。 // The ..原创 2021-07-15 09:14:46 · 273 阅读 · 0 评论 -
LeetCode-704.二分查找
问题描述: 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 class Solution { public: int search(vector<int>& nums, int target) { int nLeft = 0; int nRight= nums.size() - 1; int nMid = 0原创 2021-07-15 08:55:51 · 129 阅读 · 0 评论 -
LeetCode--1 两数之和
#include <map> class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { map<int, int> mapNum; map<int, int>::iterator iter = mapNum.begin(); for(int i = 0; i < nums.size(.原创 2021-07-14 17:51:24 · 216 阅读 · 1 评论