随笔分类 - leetcode
[Leetcode 50]多次方Pow(x, n)
摘要:【题目】 多次方计算,主要是正负两种情况 Implement pow(x, n), which calculates x raised to the power n (i.e., xn). Example 1: Input: x = 2.00000, n = 10 Output: 1024.0000
阅读全文
[Leetcode 33/81]有序旋转数组找值Search in Rotated Sorted Array
摘要:leetcode33 【题目】 顺序排列的数组,每个点值不同。以某个点进行旋转(其实就是前后两段交换位置),对旋转后数组搜索有无target,没有-1,有返回位置 (变式81不同点在于会出现重复数字) There is an integer array nums sorted in ascendin
阅读全文
[Leetcode 74/240]二维数组中找目标值Search a 2D Matrix
摘要:leetcode74 【题目】 二维矩阵里找目标值target Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: I
阅读全文
[Leetcode 278]第一个出错的版本 First Bad Version
摘要:【题目】 一个版本出错,后续版本皆错,找到第一个出错的版本 You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of yo
阅读全文
[Leetcode 349]两个数组的相同元素Intersection of Two Arrays
摘要:【题目】 找到两个数组的相同元素并输出。 Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and yo
阅读全文
[Leetcode 35]在顺序数组中找到插入位置Search Insert Position 二分
摘要:【题目】 非负的有序数组中,如果有与target相同的,输出该数位置,如果没有,输出应该将target插到哪个位置 Given a sorted array of distinct integers and a target value, return the index if the target
阅读全文
[Leetcode 69]开根号Sqrt(x) 二分查找易错点
摘要:【题目】 对非负数求平方根,不能调用系统自带库 Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digi
阅读全文
[Leetcode 130]被围区域翻牌Surrounded Regions
摘要:【题目】 其实就是矩阵里,除了与最外层边O相连的O不被翻牌成X外,其他O全部翻牌成X Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded
阅读全文
[Leetcode 695]岛屿最大面积 Max Area of Island DFS
摘要:【题目】 岛屿矩阵,0表示海洋,数字表示岛屿面积,只有上下左右代表岛屿相连,对角线不算。 求问海洋里最大的岛屿面积 You are given an m x n binary matrix grid. An island is a group of 1's (representing land) c
阅读全文
[Leetcode 494]目标和 Target Sum
摘要:【题目】 若干个数字间,使用加法或减法连接,最终得到目标和target,求所有满足条件解的个数 You are given an integer array nums and an integer target. You want to build an expression out of nums
阅读全文
[Leetcode 394]编译解码字符串Decode String
摘要:【题目】 将格式为 数[数[字母字母]数[字母]] 的字符串展开 Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string
阅读全文
[Leetcode 23]合并有序列表Merge k Sorted Lists
摘要:太久没刷题自闭了爬上来记录下 【题目】 将K个顺序排列的列表合并,输出合并后的列表 Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked-lists ar
阅读全文
[Leetcode 40]组合数和II Combination Sum II
摘要:【题目】 Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate
阅读全文
[Leetcode 39]组合数的和Combination Sum
摘要:【题目】 Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where
阅读全文
[Leetcode 72]编辑距离 Edit Distance
摘要:【题目】 Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations pe
阅读全文
[Leetcode 452] 最少需要射出多少支箭Minimum Number of Arrows to Burst Balloons 贪心 重载
摘要:【题目】 There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of th
阅读全文
[Leetcode 216]求给定和的数集合 Combination Sum III
摘要:【题目】 Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination shoul
阅读全文
[Leetcode 217&219]寻找数组中的重复值Contains Duplicate I & II
摘要:【题目1】 Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in t
阅读全文
[Leetcode easy]存些水题34、20、700
摘要:leetcode 34 最早出现和最后出现 class Solution { public int[] searchRange(int[] nums, int target) { int []ans={-1,-1} ; for(int i=0;i<nums.length;i++){ if(nums[
阅读全文
[Leetcode 37]*数独游戏 Sudoku Solver 附解释
摘要:【题目】 每一行、每一列、每个3*3的格子里只能出现一次1~9。 【思路】 参考了思路,附加了解释。 dfs遍历所有非空格子,n是已经填好的个数。 初始化条件。n=81,都填了,返回结束。对于已经填好的b[x][y] != '.'跳过,到下一个。 xy的设计保证先行后列填写。 开始填数字,valid
阅读全文
浙公网安备 33010602011771号