自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(91)
  • 收藏
  • 关注

原创 leetcode学习笔记1631 Path With Minimum Effort

leetcode学习笔记1631问题方法1问题Path With Minimum Effort最省力的路径.给定一个二维数组,值是当前的高度, 每次可以往 上, 下, 左, 右 4个方向移动, 要求返回从左上角移动到右下角时的最小努力值.从A移动到相邻点B时, 两点高度的差的绝对值就是努力值.从A移动到B边时的努力值是中途所有努力值中最大的那一个.Example 1:Input: heights = [[1,2,2],[3,8,2],[5,3,5]]Output: 2Explanat

2021-01-28 16:30:01 286

原创 leetcode学习笔记1437 Check If All 1‘s Are at Least Length K Places Away

leetcode学习笔记1437问题方法1问题Check If All 1’s Are at Least Length K Places Away检查是否所有的1之间的间隔都至少是k.Example 1:Input: nums = [1,0,0,0,1,0,0,1], k = 2Output: trueExplanation: Each of the 1s are at least 2 places away from each other.Example 2:Input: num

2021-01-25 20:53:15 182

原创 leetcode学习笔记215 kth-largest-element-in-an-array

leetcode学习笔记215问题方法1方法2问题kth-largest-element-in-an-array给定一个数组,找到里面第K大的数.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5Example 2:Input: [3,2,3,1,2,4,5,5,6] and k = 4Output: 4方法1最简单的方法就是先排列,然后找到第K大的数就可以了.时间复杂度O(NlogN).空间复杂度O(1).class So

2021-01-16 18:25:24 208

原创 leetcode学习笔记169 Majority Element

leetcode学习笔记169问题方法1方法2方法3问题Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always exist i

2020-12-13 19:23:52 190 1

原创 leetcode学习笔记150 Evaluate Reverse Polish Notation

leetcode学习笔记150问题方法1问题Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Note:Division between two integers s

2020-12-13 19:23:36 107

原创 leetcode学习笔记371 Sum of Two Integers

leetcode学习笔记371问题方法1问题Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example 1:Input: a = 1, b = 2Output: 3Example 2:Input: a = -2, b = 3Output: 1方法1自己来实现加法.不让用加减, 那就只能用位运算了.

2020-12-13 19:22:57 89

原创 leetcode学习笔记941 Valid Mountain Array

leetcode学习笔记941问题方法1问题Valid Mountain ArrayGiven an array of integers arr, return true if and only if it is a valid mountain array.Recall that arr is a mountain array if and only if:arr.length >= 3There exists some i with 0 < i < arr.length

2020-12-13 19:22:36 64

原创 leetcode学习笔记166 Fraction to Recurring Decimal

leetcode学习笔记166问题方法1问题Fraction to Recurring DecimalGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses.If mult

2020-12-10 21:12:38 119

原创 leetcode学习笔记173 Binary Search Tree Iterator

leetcode学习笔记173问题方法1方法2问题Binary Search Tree IteratorImplement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST):BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The ro

2020-12-10 20:47:48 110

原创 leetcode学习笔记29 Divide Two Integers

leetcode学习笔记29问题方法1方法2问题leetcode Two Sum方法1时间复杂度O(n2)O(n^{2})O(n2).空间复杂度O(1)O(1)O(1).方法2时间复杂度O(n)O(n)O(n).空间复杂度O(n)O(n)O(n).

2020-12-10 20:47:22 108

原创 leetcode学习笔记297 Serialize and Deserialize Binary Tree

leetcode学习笔记297问题思考方法1方法2问题Serialize and Deserialize Binary Tree思考Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connect

2020-12-09 21:25:14 98

原创 leetcode学习笔记94 Binary Tree Inorder Traversal

leetcode学习笔记94开始之前问题思考方法1方法2开始之前问题Binary Tree Inorder TraversalGiven the root of a binary tree, return the inorder traversal of its nodes’ values.Follow up:Recursive solution is trivial, could you do it iteratively?思考基础.方法1标准的递归中序遍历.时间复杂度O(n)O(n

2020-12-09 20:34:08 107

原创 leetcode学习笔记56 Merge Intervals

leetcode学习笔记56问题方法1问题Merge IntervalsGiven an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.Example 1:Input: inte

2020-12-09 14:09:19 206

原创 leetcode学习笔记34 Find First and Last Position of Element in Sorted Array

leetcode学习笔记34问题方法1问题Find First and Last Position of Element in Sorted ArrayGiven an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.If target is not found in the array, return [-1, -1].F

2020-12-09 14:01:36 85

原创 leetcode学习笔记162 Find Peak Element

leetcode学习笔记162问题方法1方法2问题 Find Peak ElementA peak element is an element that is strictly greater than its neighbors.Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of

2020-12-09 13:01:29 120

原创 leetcode学习笔记1010 Pairs of Songs With Total Durations Divisible by 60

leetcode学习笔记1010开始之前问题方法1开始之前问题Pairs of Songs With Total Durations Divisible by 60You are given a list of songs where the ith song has a duration of time[i] seconds.Return the number of pairs of songs for which their total duration in seconds is divis

2020-12-08 22:55:06 112

原创 leetcode学习笔记347 Top K Frequent Elements

leetcode学习笔记347问题思考方法1方法2问题Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]Note:You may as

2020-12-08 16:50:01 135

原创 leetcode学习笔记78 Subsets

leetcode学习笔记78问题方法1方法2问题SubsetsGiven an integer array nums, return all possible subsets (the power set).The solution set must not contain duplicate subsets.Example 1:Input: nums = [1,2,3]Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]Example 2

2020-12-08 16:01:21 89

原创 leetcode学习笔记22 Generate Parentheses

leetcode学习笔记22问题思考方法1问题Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.Example 1:Input: n = 3Output: ["((()))","(()())","(())()","()(())","()()()"]Example 2:Input: n = 1

2020-12-08 13:00:44 87

原创 leetcode学习笔记59 Spiral Matrix II

leetcode学习笔记59问题思考方法1方法2问题Spiral Matrix IIGiven a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.Example 1:Input: n = 3Output: [[1,2,3],[8,9,4],[7,6,5]]Example 2:Input: n = 1Output: [[1]]Constr

2020-12-07 20:50:06 70

原创 leetcode学习笔记160 Intersection of Two Linked Lists

leetcode学习笔记160问题思考方法1问题 Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Input: inters

2020-12-07 16:45:50 79

原创 leetcode学习笔记328 Odd Even Linked List

leetcode学习笔记328 问题方法1方法2问题Odd Even Linked ListGiven a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in place. Th

2020-12-06 21:11:35 62

原创 leetcode学习笔记334 Increasing Triplet Subsequence

leetcode学习笔记334问题思考方法1问题Increasing Triplet SubsequenceGiven an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, ksuch that arr[i] < arr[j

2020-12-05 22:17:38 60

原创 leetcode学习笔记49 Group Anagrams

leetcode学习笔记49问题思考方法1问题Group AnagramsGiven an array of strings strs, group the anagrams together. You can return the answer in any order.An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all

2020-12-05 21:06:07 116

原创 leetcode学习笔记73 Set Matrix Zeroes

leetcode学习笔记73问题思考方法1问题Set Matrix ZeroesGiven an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.Follow up:A straight forward solution using O(mn) space is probably a bad idea.A simple improvement uses O(m + n) s

2020-12-05 19:41:35 107

原创 leetcode学习笔记300 Longest Increasing Subsequence

leetcode学习笔记300问题思考方法1方法2问题Longest Increasing SubsequenceGiven an integer array nums, return the length of the longest strictly increasing subsequence.A subsequence is a sequence that can be derived from an array by deleting some or no elements without

2020-12-05 16:14:16 119

原创 leetcode学习笔记322 Coin Change

leetcode学习笔记322问题思考方法1问题Coin ChangeYou are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up

2020-12-05 15:33:07 70

原创 leetcode学习笔记55 jump-game

leetcode学习笔记55问题思考方法1问题jump-gameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the

2020-12-05 14:26:12 85

原创 leetcode学习笔记382 Linked List Random Node

leetcode学习笔记382问题思考方法1方法2问题Linked List Random NodeGiven a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen.Follow up:What if the linked list is extremely large and its leng

2020-12-05 13:59:57 72

原创 leetcode学习笔记897 Increasing Order Search Tree

leetcode学习笔记897开始之前问题思考方法1方法2开始之前在做leetcode的每日一题的时候做到了这一次.其实很简单, 是个easy的题目.可能是因为很久没做了tree的题目了, 这个题目竟然卡住了.无地自容.天冷难道把脑子也一起冻住了吗?问题Increasing Order Search TreeGiven the root of a binary search tree, rearrange the tree in in-order so that the leftmost n

2020-12-05 11:28:51 101

原创 leetcode学习笔记14 Longest Common Prefix

leetcode学习笔记14问题思考方法1方法2问题lLongest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: strs = [“flower”,“flow”,“flight”]Output:

2020-11-20 13:32:19 107

原创 leetcode学习笔记13 Roman to Integer

leetcode学习笔记13问题思考方法1问题Roman to IntegerRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 500M

2020-11-20 13:00:14 112

原创 leetcode学习笔记12 Integer to Roman

leetcode学习笔记12问题思考方法1方法2问题Integer to RomanRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 500M 1000

2020-11-19 15:11:59 117

原创 leetcode学习笔记11 Container With Most Water

leetcode学习笔记11问题思考方法1方法2问题Container With Most WaterGiven n non-negative integers a1a_1a1​, a2a_2a2​, …, ana_nan​ , where each represents a point at coordinate (i, aia_iai​). n vertical lines are drawn such that the two endpoints of the line i is at (i,

2020-11-19 14:03:43 71

原创 leetcode学习笔记10 Regular Expression Matching

leetcode学习笔记10问题思考方法1方法2问题regular-expression-matchingGiven an input string ( sss ) and a pattern ( ppp ), implement regular expression matching with support for ‘...’ and ‘∗*∗’ where:‘...’ Matches any single character.​​​​‘∗*∗’ Matches zero or more o

2020-11-19 13:16:07 69

原创 leetcode学习笔记09 palindrome-number

leetcode学习笔记09问题思考方法1方法2问题palindrome-numberDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Follow up: Could you solve it without converting the integer to a string?Example 1:Input:

2020-10-30 16:30:01 125

原创 leetcode学习笔记08 string-to-integer-atoi

leetcode学习笔记08开始之前问题思考方法1方法2开始之前问题string-to-integer-atoiImplement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from

2020-10-30 13:32:59 65

原创 leetcode学习笔记07 reverse-integer

leetcode学习笔记07问题思考方法1方法2问题reverse-integerGiven a 32-bit signed integer, reverse digits of an integer.Note:Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpos

2020-10-28 13:14:19 67

原创 leetcode学习笔记06 zigzag-conversion

leetcode学习笔记06问题思考问题zigzag-conversionThe string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I GY I RAnd

2020-10-22 15:57:00 94

原创 leetcode学习笔记05 palindromic-substring

leetcode学习笔记05开始之前问题思考方法1方法2开始之前两周前去考了新Toeic的Listening&writing , 今天可以查成绩了. 总分814. 挺意外, 原本预想大概是600多.虽说意外, 仔细想想, 这个世界还是挺公平的, 想得到什么, 就得付出相应的代价. 每天上下班在电车上背单词, 这个功夫没白下.也希望自己可以慢慢的把leetcode 的专题能慢慢的补起来.想想自己也是懒, 题都做到300了, 才想起来整理.问题longest-palindromic-su

2020-10-21 20:44:54 149

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除