![](https://img-blog.csdnimg.cn/20190703081212136.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode刷题
文章平均质量分 85
每周会刷一下LeetCode上的算法题,记录过程,也分享心得。
码农土豆
如果你一直不踏出第一步,就永远提不起干劲。
展开
-
2021年3月刷题(下) Spiral Matrix,Merge Interval
题目都来源于leetcode网站。题目的图片来自或参考原网站绘制。第三题54. Spiral MatrixGiven an m x n matrix, return all elements of the matrix in spiral order.Example 1:Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]Output: [1,2,3,6,9,8,7,4,5]输入为一个m x n的数组,从位置[0,0]开始按照顺时针方向螺旋型遍历数组,输出遍历的原创 2021-03-28 20:35:49 · 123 阅读 · 0 评论 -
2021年3月刷题(上) Unique Paths,Subsets
题目都来源于leetcode网站。题目的图片参考原网站绘制。第一周:62. Unique PathsA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the botto原创 2021-03-21 16:55:17 · 133 阅读 · 0 评论 -
LeetCode刷题-JumpGameII
Jump Game IIGiven 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.You...原创 2020-01-13 14:29:25 · 169 阅读 · 0 评论 -
LeetCode刷题-WildcardMatching-实现正则*和?
wildcard-matchingGiven an input string (s) and a pattern (p), implement wildcard pattern matching with support for ‘?’ and ‘’.‘?’ Matches any single character.'’ Matches any sequence of characters...原创 2020-01-09 14:36:05 · 137 阅读 · 0 评论 -
LeetCode刷题-191119-Multiply Strings
Multiply StringsGiven two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1:Input: num1 = “2”, num2 = “3”Outp...原创 2019-11-19 10:43:14 · 149 阅读 · 0 评论 -
LeetCode刷题-191028-Trapping Rain Water-收集雨水
Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is ...原创 2019-10-29 09:20:53 · 140 阅读 · 0 评论 -
LeetCode刷题-191014-First Missing Positive-没有出现的最小正整数
First Missing PositiveGiven an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9...原创 2019-10-14 13:23:08 · 743 阅读 · 0 评论 -
LeetCode刷题-191008,计数规则数列,找出序列中满足条件的组合(和找零钱有点相识)
Count and SayThe count-and-say sequence is the sequence of integers with the first five terms as following: 1,11, 21,1211,1112211 is read off as “one 1” or 11.11 is read off as “two 1s” or 21.21 ...原创 2019-10-12 16:59:34 · 215 阅读 · 0 评论 -
LeetCode刷题-190812-下一个排列(全排列知识扩展)
Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the ...原创 2019-08-13 14:51:44 · 262 阅读 · 0 评论 -
LeetCode刷题-190709-扩展:三水桶等分8升水的问题,妖怪和和尚过河问题
三水桶等分8升水的问题参考书:《算法的乐趣》王晓华著问题描述有三个容积分别是 3 升、5 升和 8 升的水桶,其中容积为8升的水桶中装满水,容积为 3 升和容积为 5 升的水桶是空的。三个水桶都没有体积刻度,现在需要将大水桶中的8升水等分成两份,每份都是4升水,附加条件是只能使用另外两个空水桶,不能使用其他容器。好像是小学的暑假作业中的题目,答案就不说了,主要分析如何用代码来解题。用人的思...原创 2019-08-12 09:56:49 · 1269 阅读 · 0 评论 -
LeetCode刷题-190729-查找字符串中的单词组合
Substring with Concatenation of All WordsYou are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenatio...原创 2019-07-30 15:49:40 · 639 阅读 · 0 评论 -
LeetCode刷题-190715-字符串查找-两个int数除法
Implement strStr()Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = “hello”, needle = “ll”Out...原创 2019-07-25 13:30:03 · 124 阅读 · 0 评论 -
LeetCode刷题-190709-扩展:阿拉伯数字和中文数字转换
前面刷过一个题,关于罗马字和阿拉伯数字转换,我之前的文章链接:https://blog.csdn.net/sleepingboy888/article/details/89814335最近在看《算法的乐趣》王晓华著,其中的“阿拉伯数字和中文数字”。阿拉伯数字转中文数字...原创 2019-07-11 13:23:46 · 5883 阅读 · 2 评论 -
LeetCode刷题-190709-统计整形数组中不同值的数量
题目:Remove Duplicates from Sorted ArrayGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for ano...原创 2019-07-09 10:09:05 · 157 阅读 · 0 评论 -
LeetCode刷题-190703-成对交换链表节点
题目:Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes, only nodes itself may be changed.Example:Given 1-&...原创 2019-07-04 09:28:19 · 141 阅读 · 0 评论 -
LeetCode刷题-190906,被旋转的有序int数组中查找,在数组中找到目标值出现的起止点
Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a tar...原创 2019-09-06 14:02:52 · 190 阅读 · 0 评论 -
LeetCode刷题-190829,找出由‘(’,‘)’组成的字符串中最长的符合括号规则的串长度
Longest Valid ParenthesesGiven a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Explan...原创 2019-08-29 09:55:58 · 330 阅读 · 0 评论 -
LeetCode刷题-190918,数独出题是否符合规则,解数独
Valid SudokuDetermine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:1.Each row must contain the digits 1-9 without repetition.2.Each c...原创 2019-09-25 13:16:25 · 324 阅读 · 0 评论