Search in Rotated Sorted Array
LeetCode https://leetcode.cn/problems/search-in-rotated-sorted-array/ 题目描述 整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k < nums.length)上进行了 旋转,使数组变为 [nums[k], nums[k+1], …...
LeetCode https://leetcode.cn/problems/search-in-rotated-sorted-array/ 题目描述 整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k < nums.length)上进行了 旋转,使数组变为 [nums[k], nums[k+1], …...
First Bad Version Leetcode https://leetcode.cn/problems/first-bad-version/ 题目描述 你是产品经理,目前正在带领一个团队开发新的产品。不幸的是,你的产品的最新版本没有通过质量检测。由于每个版本都是基于之前的版本开发的,所以错误的版本之后的所有版本都是错的。 假设你有 n 个版本 [1, 2, …, n],你想找...
几乎所有的搜索问题都可以以这个代码为模板 Leetcode https://leetcode.cn/problems/subsets/ 题目描述 给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。 解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。 示例 1: 输入:nums = [1, 2, 3] 输出:[ [], [1], [...
First Postion of Target Leetcode https://leetcode.cn/problems/binary-search/ 题目描述 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 示例 1: 输入: nums = [-1,0,...
Vim 实操教程(Learning Vim) English 中文 以我个人学习 Vim 的经验来看,通过看文档或看其他人操作其实是很难真正学会 Vim 的,你必须在实际 应用中,进入真实场景才能逐渐熟悉并掌握相关命令。 因此,为了同时满足学习和操作的需求,项目中的文件都采用了 Markdown 格式,既可以当作说明文档来 阅...
public int[] quickSort(int[] array) { helper(array, 0, array.length - 1); return array; } // end quickSort // Divide public void helper(int[] array, int left, int right) { if (left >...
Merge Sorted Array Lintcode https://www.lintcode.com/problem/64/ Leetcode https://leetcode.com/problems/merge-sorted-array/ 题目描述 给你两个按 非递减顺序 排列的整数数组 nums1 和 nums2,另有两个整数 m 和 n ,分别表示 nums1 和 num...
Outline Recursion Combination Permutation Graph Non-Recursion 什么时候使用 DFS? 回顾:还记得什么时候使用 BFS 吗? 通用的DFS时间复杂度计算通用公式 搜索的时间复杂度:O(答案总数 * 构造每个答案的时间) 举例:Subsets问题,求所有的子集。子集个数一共 2^n,每个集...
Outline Time Complexity Training ii Traverse in Binary Tree Preorder / Inorder / Postorder DFS in Binary Tree Preorder / Inorder / Postorder ...
Outline 二叉树上的宽搜 BFS in Binary Tree 图上的宽搜 BFS in Graph 拓扑排序 Topological Sorting 棋盘上的宽搜 BFS 什么时候应该使用BFS? 图的遍历 Traversal in Graph 层次遍历 Level Order Traversal 由点及面 Co...