原文链接: https://leetcode-cn.com/problems/palindromic-substrings 英文原文Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of charac…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/replace-words 英文原文In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example, when the root "an" is followed by …
原文链接: https://leetcode-cn.com/problems/2-keys-keyboard 英文原文There is only one character 'A' on the screen of a notepad. You can perform two operations on this notepad for each step: Copy All: You can copy all the characters present on the screen (a pa…
原文链接: https://leetcode-cn.com/problems/find-duplicate-subtrees 英文原文Given the root of a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate …
原文链接: https://leetcode-cn.com/problems/maximum-binary-tree 英文原文You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create a root node whose value is the maxim…
原文链接: https://leetcode-cn.com/problems/print-binary-tree 英文原文Given the root of a binary tree, construct a 0-indexed m x n string matrix res that represents a formatted layout of the tree. The formatted layout matrix should be constructed using the fo…
原文链接: https://leetcode-cn.com/problems/find-k-closest-elements 英文原文Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to…
原文链接: https://leetcode-cn.com/problems/split-array-into-consecutive-subsequences 英文原文You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences such that both of…
原文链接: https://leetcode-cn.com/problems/maximum-width-of-binary-tree 英文原文Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined …
原文链接: https://leetcode-cn.com/problems/non-decreasing-array 英文原文Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] <= nums[i +…
原文链接: https://leetcode-cn.com/problems/beautiful-arrangement-ii 英文原文Given two integers n and k, construct a list answer that contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is answer =…
原文链接: https://leetcode-cn.com/problems/trim-a-binary-search-tree 英文原文Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should no…
原文链接: https://leetcode-cn.com/problems/maximum-swap 英文原文You are given an integer num. You can swap two digits at most once to get the maximum valued number. Return the maximum valued number you can get. Example 1: Input: num = 2736 Output: 7236 Expla…
原文链接: https://leetcode-cn.com/problems/bulb-switcher-ii 英文原文There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a different functionality where: Button 1: Flips…
原文链接: https://leetcode-cn.com/problems/number-of-longest-increasing-subsequence 英文原文Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: nums = [1…
原文链接: https://leetcode-cn.com/problems/implement-magic-dictionary 英文原文Design a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one character in this string to match …
原文链接: https://leetcode-cn.com/problems/map-sum-pairs 英文原文Design a map that allows you to do the following: Maps a string key to a given value. Returns the sum of the values that have a key with a prefix equal to a given string. Implement the MapSum c…
原文链接: https://leetcode-cn.com/problems/valid-parenthesis-string 英文原文Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: Any left parenthesis '(' must have…
原文链接: https://leetcode-cn.com/problems/redundant-connection 英文原文In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edg…
原文链接: https://leetcode-cn.com/problems/repeated-string-match 英文原文Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b to be a substring of a af…
原文链接: https://leetcode-cn.com/problems/longest-univalue-path 英文原文Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through the root. The length of the…
原文链接: https://leetcode-cn.com/problems/knight-probability-in-chessboard 英文原文On an n x n chessboard, a knight starts at the cell (row, column) and attempts to make exactly k moves. The rows and columns are 0-indexed, so the top-left cell is (0, 0), an…
原文链接: https://leetcode-cn.com/problems/employee-importance 英文原文You have a data structure of employee information, including the employee's unique ID, importance value, and direct subordinates' IDs. You are given an array of employees employees where:…
原文链接: https://leetcode-cn.com/problems/top-k-frequent-words 英文原文Given an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequ…
原文链接: https://leetcode-cn.com/problems/max-area-of-island 英文原文You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are…
原文链接: https://leetcode-cn.com/problems/partition-to-k-equal-sum-subsets 英文原文Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal. Example 1: Input: nums = […
原文链接: https://leetcode-cn.com/problems/minimum-ascii-delete-sum-for-two-strings 英文原文Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Input: s1 = "sea", s2 = "eat" Output: 231 Explana…
原文链接: https://leetcode-cn.com/problems/subarray-product-less-than-k 英文原文Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k. Example…
原文链接: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee 英文原文You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee. Find the ma…
原文链接: https://leetcode-cn.com/problems/maximum-length-of-repeated-subarray 英文原文Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Example 1: Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] O…