原文链接: https://leetcode-cn.com/problems/median-of-two-sorted-arrays 英文原文Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1…
分类详情
困难 分类
原文链接: https://leetcode-cn.com/problems/regular-expression-matching 英文原文Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character. '*' Matches zero or more o…
原文链接: https://leetcode-cn.com/problems/merge-k-sorted-lists 英文原文You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lis…
原文链接: https://leetcode-cn.com/problems/reverse-nodes-in-k-group 英文原文Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. …
原文链接: https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words 英文原文You are given a string s and an array of strings words of the same length. Return all starting indices of substring(s) in s that is a concatenation of each word in w…
原文链接: https://leetcode-cn.com/problems/longest-valid-parentheses 英文原文Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: s = "(()" Output: 2 Explanatio…
原文链接: https://leetcode-cn.com/problems/sudoku-solver 英文原文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 must occur exactly once in each row. Each …
原文链接: https://leetcode-cn.com/problems/first-missing-positive 英文原文Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses constant extra space. Example 1: Inp…
原文链接: https://leetcode-cn.com/problems/trapping-rain-water 英文原文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. Example 1: Input: height = [0,1,0,2,1,0,1,3…
原文链接: https://leetcode-cn.com/problems/wildcard-matching 英文原文Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character. '*' Matches any sequence of characters…
原文链接: https://leetcode-cn.com/problems/n-queens 英文原文The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You…
原文链接: https://leetcode-cn.com/problems/n-queens-ii 英文原文The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queen…
原文链接: https://leetcode-cn.com/problems/valid-number 英文原文A valid number can be split up into these components (in order): A decimal number or an integer. (Optional) An 'e' or 'E', followed by an integer. A decimal number can be split up into these com…
原文链接: https://leetcode-cn.com/problems/text-justification 英文原文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) justified. You should pack your word…
原文链接: https://leetcode-cn.com/problems/edit-distance 英文原文Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character De…
原文链接: https://leetcode-cn.com/problems/minimum-window-substring 英文原文Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. I…
原文链接: https://leetcode-cn.com/problems/largest-rectangle-in-histogram 英文原文Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. Example …
原文链接: https://leetcode-cn.com/problems/maximal-rectangle 英文原文Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1"…
原文链接: https://leetcode-cn.com/problems/scramble-string 英文原文We can scramble a string s to get a string t using the following algorithm: If the length of the string is 1, stop. If the length of the string is > 1, do the following: Split the string into…
原文链接: https://leetcode-cn.com/problems/distinct-subsequences 英文原文Given two strings s and t, return the number of distinct subsequences of s which equals t. A string's subsequence is a new string formed from the original string by deleting some (can b…
原文链接: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii 英文原文You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete at most two transacti…
原文链接: https://leetcode-cn.com/problems/binary-tree-maximum-path-sum 英文原文A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once.…
原文链接: https://leetcode-cn.com/problems/word-ladder-ii 英文原文A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words diff…
原文链接: https://leetcode-cn.com/problems/word-ladder 英文原文A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words differs…
原文链接: https://leetcode-cn.com/problems/palindrome-partitioning-ii 英文原文Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. Example 1: Input: s = "…
原文链接: https://leetcode-cn.com/problems/candy 英文原文There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requirements: Each…
原文链接: https://leetcode-cn.com/problems/word-break-ii 英文原文Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note …
原文链接: https://leetcode-cn.com/problems/max-points-on-a-line 英文原文Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. Example 1: Input: points …
原文链接: https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii 英文原文Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become: [4,5,6,7,0,1,4] if…
原文链接: https://leetcode-cn.com/problems/maximum-gap 英文原文Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0. You must write an algorithm …
1 / 13