原文链接: https://leetcode-cn.com/problems/contiguous-array 英文原文Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. Example 1: Input: nums = [0,1] Output: 2 Explanation: [0, 1] is the longest con…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/beautiful-arrangement 英文原文Suppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every i (1 <= i <= n), either of the fol…
原文链接: https://leetcode-cn.com/problems/swapping-nodes-in-a-linked-list 英文原文You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node fro…
原文链接: https://leetcode-cn.com/problems/minesweeper 英文原文Let's play the minesweeper game (Wikipedia, online game)! You are given an m x n char matrix board representing the game board where: 'M' represents an unrevealed mine, 'E' represents an unreveal…
原文链接: https://leetcode-cn.com/problems/encode-and-decode-tinyurl 英文原文Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/desig…
原文链接: https://leetcode-cn.com/problems/complex-number-multiplication 英文原文A complex number can be represented as a string on the form "real+imaginaryi" where: real is the real part and is an integer in the range [-100, 100]. imaginary is the imaginary…
原文链接: https://leetcode-cn.com/problems/convert-bst-to-greater-tree 英文原文Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater …
原文链接: https://leetcode-cn.com/problems/minimum-time-difference 英文原文Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list. Example 1: Input: timePoints = ["23:59","00…
原文链接: https://leetcode-cn.com/problems/single-element-in-a-sorted-array 英文原文You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single eleme…
原文链接: https://leetcode-cn.com/problems/01-matrix 英文原文Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0…
原文链接: https://leetcode-cn.com/problems/number-of-provinces 英文原文There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected ind…
原文链接: https://leetcode-cn.com/problems/optimal-division 英文原文You are given an integer array nums. The adjacent integers in nums will perform the float division. For example, for nums = [2,3,4], we will evaluate the expression "2/3/4". However, you can…
原文链接: https://leetcode-cn.com/problems/brick-wall 英文原文There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The tot…
原文链接: https://leetcode-cn.com/problems/next-greater-element-iii 英文原文Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, …
原文链接: https://leetcode-cn.com/problems/subarray-sum-equals-k 英文原文Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Inp…
原文链接: https://leetcode-cn.com/problems/array-nesting 英文原文You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1]. You should build a set s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], .…
原文链接: https://leetcode-cn.com/problems/permutation-in-string 英文原文Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2. Example …
原文链接: https://leetcode-cn.com/problems/out-of-boundary-paths 英文原文There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent cells in the grid (possib…
原文链接: https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray 英文原文Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in asce…
原文链接: https://leetcode-cn.com/problems/delete-operation-for-two-strings 英文原文Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either s…
原文链接: https://leetcode-cn.com/problems/valid-square 英文原文Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square. The coordinate of a point pi is represented as [xi, yi]. The input is not g…
原文链接: https://leetcode-cn.com/problems/find-duplicate-file-in-system 英文原文Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms…
原文链接: https://leetcode-cn.com/problems/valid-triangle-number 英文原文Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: nums = [2,2,3,4…
原文链接: https://leetcode-cn.com/problems/task-scheduler 英文原文Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time…
原文链接: https://leetcode-cn.com/problems/add-one-row-to-tree 英文原文Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Give…
原文链接: https://leetcode-cn.com/problems/sum-of-square-numbers 英文原文Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: c = 5 Output: true Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input:…
原文链接: https://leetcode-cn.com/problems/exclusive-time-of-functions 英文原文On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. Function calls are stored in a call stack: when a function …
原文链接: https://leetcode-cn.com/problems/shopping-offers 英文原文In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale p…
原文链接: https://leetcode-cn.com/problems/solve-the-equation 英文原文Solve a given equation and return the value of 'x' in the form of a string "x=#value". The equation contains only '+', '-' operation, the variable 'x' and its coefficient. You should retur…
原文链接: https://leetcode-cn.com/problems/maximum-length-of-pair-chain 英文原文You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be forme…