随笔分类 -  leetcode

leetcode 常见题目
摘要:给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 方法一、 按照顺序四个方向,为一组循环。如果到边界,选择下一个方向做 阅读全文
posted @ 2022-05-02 22:41 diameter 阅读(220) 评论(0) 推荐(0) 编辑
摘要:(简单) 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 示例 1: 输入:nums = [-2,1,-3,4,-1,2,1,-5,4] 输出:6 解释:连续子数组 [4,-1,2,1] 的和最大,为 6 阅读全文
posted @ 2022-05-01 21:11 diameter 阅读(31) 评论(0) 推荐(0) 编辑
摘要:Implement pow(x, n), which calculates x raised to the power n (i.e. xn). 方法一: 递归 public double quickMul(double x, long N) { if (N == 0) { return 1.0; 阅读全文
posted @ 2020-12-23 14:12 diameter 阅读(58) 评论(0) 推荐(0) 编辑
摘要:Given 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 rearrang 阅读全文
posted @ 2020-12-23 13:57 diameter 阅读(70) 评论(0) 推荐(0) 编辑
摘要:You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means 阅读全文
posted @ 2020-12-23 13:38 diameter 阅读(106) 评论(0) 推荐(0) 编辑
摘要:Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. 方法: 回溯法,去重 boolean[] vis; pu 阅读全文
posted @ 2020-12-23 13:34 diameter 阅读(58) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. 方法 : 回溯法。 public List<List<Int 阅读全文
posted @ 2020-12-23 13:18 diameter 阅读(86) 评论(0) 推荐(0) 编辑
摘要:Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your 阅读全文
posted @ 2020-12-23 11:21 diameter 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character. 阅读全文
posted @ 2020-12-23 10:16 diameter 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You mus 阅读全文
posted @ 2020-12-22 19:00 diameter 阅读(93) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Input: 阅读全文
posted @ 2020-12-20 09:37 diameter 阅读(116) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted integer array nums, find the smallest missing positive integer. Follow up: Could you implement an algorithm that runs in O(n) time a 阅读全文
posted @ 2020-12-19 20:42 diameter 阅读(74) 评论(0) 推荐(0) 编辑
摘要:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb 阅读全文
posted @ 2020-12-19 16:32 diameter 阅读(99) 评论(0) 推荐(0) 编辑
摘要:Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen nu 阅读全文
posted @ 2020-12-18 16:41 diameter 阅读(90) 评论(0) 推荐(0) 编辑
摘要:The count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = "1" countAndSay(n) is the way you would " 阅读全文
posted @ 2020-12-18 15:34 diameter 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9 阅读全文
posted @ 2020-12-18 14:44 diameter 阅读(77) 评论(0) 推荐(0) 编辑
摘要:Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the dig 阅读全文
posted @ 2020-12-17 17:34 diameter 阅读(99) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if i 阅读全文
posted @ 2020-12-17 14:55 diameter 阅读(69) 评论(0) 推荐(0) 编辑
摘要:Given 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 th 阅读全文
posted @ 2020-12-17 14:22 diameter 阅读(76) 评论(0) 推荐(0) 编辑
摘要:You are given an integer array nums sorted in ascending order, and an integer target. Suppose that nums is rotated at some pivot unknown to you before 阅读全文
posted @ 2020-12-17 10:43 diameter 阅读(87) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示