随笔分类 - LeetCode
摘要:Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Ex
阅读全文
摘要:You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0]. Each element nums[i] represents the maximum len
阅读全文
摘要:You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum ju
阅读全文
摘要:Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals
阅读全文
摘要:You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval
阅读全文
摘要:Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3 Output: [[1,2,3],[8,9,
阅读全文
摘要:Given 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,
阅读全文
摘要:Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Example 1: Input: nums = [1,
阅读全文
摘要:Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,
阅读全文
摘要:The set [1, 2, 3, ..., n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following s
阅读全文
摘要:Given the head of a linked list, rotate the list to the right by k places. Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] Example 2:
阅读全文
摘要:You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to th
阅读全文
摘要:There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-rig
阅读全文
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
阅读全文
摘要:Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right
阅读全文
摘要:Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simpl
阅读全文
摘要:Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.
阅读全文
摘要:Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations
阅读全文
摘要:Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. You must do it in place. Example 1: Input: matrix = [[
阅读全文
摘要:Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in
阅读全文