08 2021 档案
[Leetcode 445]正序链表相加Add Two Numbers II
摘要:【题目】 将链表组成的数相加 leetcode2变式,2题是高位在后,现在是高位在前节点 You are given two non-empty linked lists representing two non-negative integers. The most significant dig 阅读全文
posted @ 2021-08-31 17:11 alau 阅读(79) 评论(0) 推荐(0)
[Leetcode 206]反转链表Reverse Linked List
摘要:【题目】 反转链表是之后很多题的基础 把链表12345反转成54321 Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [ 阅读全文
posted @ 2021-08-31 16:51 alau 阅读(36) 评论(0) 推荐(0)
[Leetcode 2]两数相加链表Add Two Numbers
摘要:【题目】 将两个用list存储的数字相加,返回相加后的值 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, 阅读全文
posted @ 2021-08-31 14:31 alau 阅读(39) 评论(0) 推荐(0)
[Leetcode 44]合并有序列表Merge k Sorted Lists
摘要:【题目】 将两个有序链表合并成一个有序链表 Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the firs 阅读全文
posted @ 2021-08-30 20:40 alau 阅读(44) 评论(0) 推荐(0)
[Leetcode 11]容器中装最多的水Container With Most Water
摘要:【题目】 木桶短板,能装的最多水,由最短的那条决定 Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are dr 阅读全文
posted @ 2021-08-23 23:23 alau 阅读(59) 评论(0) 推荐(0)
[整理]K sum系列问题 N数之和 多指针模板 leetcode15/16/18/167/259/454
摘要:【整体思路】 先Arrays.sort()排序,不然后续指针没法用 对于K数之和,固定K-2个指针(循环),再用两指针一头一尾,根据sum大了小了,调左或调右 4数之和,2固定2移动; 3数之和,1固定2移动; 一定要记得去重,不仅为了减少工作量,也是确保输出结果的唯一 【题目】 leetcode1 阅读全文
posted @ 2021-08-23 22:39 alau 阅读(100) 评论(0) 推荐(0)
[Leetcode 781]森林中的兔子 Rabbits in Forest 巧妙
摘要:【题目】 问每只兔子,有多少只和你颜色相同的(颜色问全了,不一定问道每只兔子),求这片森林中至少有多少只兔子 There is a forest with an unknown number of rabbits. We asked n rabbits "How many rabbits have 阅读全文
posted @ 2021-08-23 19:09 alau 阅读(66) 评论(0) 推荐(0)
[Leetcode 26/27/80/283/977]移除(重复)元素 指针专题整理
摘要:【总结】 参考https://www.bilibili.com/video/BV1Pv4y1Z76N 适用情况:大部分需数组升序 【代码】 27 移除元素 不用管移除后半部分是否为正确答案,所以可直接nums[flag]=nums[i] class Solution { public int rem 阅读全文
posted @ 2021-08-23 16:52 alau 阅读(49) 评论(0) 推荐(0)
[Leetcode 88]合并有序数组Merge Sorted Array 归并排序
摘要:【题目】 合并两个数组,两个数组已分别顺序排好,不能使用额外数组,就存在nums1中 You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, 阅读全文
posted @ 2021-08-23 11:23 alau 阅读(75) 评论(0) 推荐(0)
[Leetcode 44]合并有序列表Merge k Sorted Lists
摘要:【题目】 找到第一个没有重复出现的字母 Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: I 阅读全文
posted @ 2021-08-22 22:44 alau 阅读(51) 评论(0) 推荐(0)
[整理]达到目标和的问题
摘要:待整理,N数之和,数组中选数列/数字达到特定值,硬币特定值 硬币;https://www.bilibili.com/video/BV1cT4y1w7Ct 阅读全文
posted @ 2021-08-22 15:10 alau 阅读(27) 评论(0) 推荐(0)
[Leetcode 198/213/337]强盗偷家 House Robber 三题DP整理
摘要:【题目1】 此系列有三题,都是强盗偷家不能偷相邻邻居,否则会被发现。问最多能偷多少钱 You are a professional robber planning to rob houses along a street. Each house has a certain amount of mon 阅读全文
posted @ 2021-08-22 13:10 alau 阅读(92) 评论(0) 推荐(0)
[Leetcode 162]爬楼梯最小耗费Min Cost Climbing Stairs**
摘要:【题目】 爬楼梯变式,可以上1/2台阶,每个台阶有cost,求爬上去的最小耗费 You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cos 阅读全文
posted @ 2021-08-22 11:30 alau 阅读(75) 评论(0) 推荐(0)
[Leetcode 102/107]比较
摘要:待 阅读全文
posted @ 2021-08-20 18:58 alau 阅读(20) 评论(0) 推荐(0)
[Leetcode 162]寻找峰值 Find Peak Element**
摘要:【题目】 寻找峰值返回坐标,比左右都大,时间复杂度必须是 O(log n) A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a pe 阅读全文
posted @ 2021-08-19 14:58 alau 阅读(64) 评论(0) 推荐(0)
[Leetcode 152]旋转数组中找到最小值Find Minimum in Rotated Sorted Array
摘要:【题目】 说了一堆就是在旋转后的顺序数组中找最小值,时间复杂度必须是 O(log n) Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the 阅读全文
posted @ 2021-08-19 14:17 alau 阅读(62) 评论(0) 推荐(0)
[Leetcode 718]最长重复子数列Maximum Length of Repeated Subarray
摘要:【题目】 两个数组,求他们最长的相同子串长度,数组长度不一定相同 Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Exampl 阅读全文
posted @ 2021-08-19 14:02 alau 阅读(61) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-19 13:27 alau 阅读(45) 评论(0) 推荐(0)
[Leetcode 33/81]有序旋转数组找值Search in Rotated Sorted Array
摘要:leetcode33 【题目】 顺序排列的数组,每个点值不同。以某个点进行旋转(其实就是前后两段交换位置),对旋转后数组搜索有无target,没有-1,有返回位置 (变式81不同点在于会出现重复数字) There is an integer array nums sorted in ascendin 阅读全文
posted @ 2021-08-19 09:05 alau 阅读(54) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-18 21:16 alau 阅读(89) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-18 20:55 alau 阅读(43) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-18 16:45 alau 阅读(113) 评论(0) 推荐(0)
[Leetcode 35]在顺序数组中找到插入位置Search Insert Position 二分
摘要:【题目】 非负的有序数组中,如果有与target相同的,输出该数位置,如果没有,输出应该将target插到哪个位置 Given a sorted array of distinct integers and a target value, return the index if the target 阅读全文
posted @ 2021-08-18 16:22 alau 阅读(65) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-18 15:44 alau 阅读(181) 评论(0) 推荐(0)
待做补二分[leetocde 1631] 最小体力消耗路径
摘要:主要思想【并查集/Kruskal】、【二分dfs/bfs】、【Dijkstra】 二分查找看完再来 阅读全文
posted @ 2021-08-17 21:40 alau 阅读(27) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-17 21:09 alau 阅读(67) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-17 19:56 alau 阅读(60) 评论(0) 推荐(0)
[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 阅读全文
posted @ 2021-08-17 19:13 alau 阅读(66) 评论(0) 推荐(0)
[Leetcode 394]编译解码字符串Decode String
摘要:【题目】 将格式为 数[数[字母字母]数[字母]] 的字符串展开 Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string 阅读全文
posted @ 2021-08-16 19:25 alau 阅读(69) 评论(0) 推荐(0)