原文链接: https://leetcode-cn.com/problems/longest-zigzag-path-in-a-binary-tree 英文原文You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If the …
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/product-of-the-last-k-numbers 英文原文Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement the ProductOfNumbers class: ProductOfNumbers() In…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-events-that-can-be-attended 英文原文Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an event i at any day d wh…
原文链接: https://leetcode-cn.com/problems/linked-list-in-binary-tree 英文原文Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked list starting from the head correspond to some downward path c…
原文链接: https://leetcode-cn.com/problems/cinema-seat-allocation 英文原文 A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. Given the array reservedSeats containing th…
原文链接: https://leetcode-cn.com/problems/sort-integers-by-the-power-value 英文原文The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: if x is even then x = x / 2 if x is odd then x = 3 * x + 1…
原文链接: https://leetcode-cn.com/problems/bulb-switcher-iii 英文原文There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off. At moment k (for k from 0 to n - 1), we turn on the light[…
原文链接: https://leetcode-cn.com/problems/time-needed-to-inform-all-employees 英文原文A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID. Each employee has one direct manager given in…
原文链接: https://leetcode-cn.com/problems/design-a-stack-with-increment-operation 英文原文Design a stack which supports the following operations. Implement the CustomStack class: CustomStack(int maxSize) Initializes the object with maxSize which is the maxi…
原文链接: https://leetcode-cn.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree 英文原文Given two binary trees original and cloned and given a reference to a node target in the original tree. The cloned tree is a copy of the ori…
原文链接: https://leetcode-cn.com/problems/circle-and-rectangle-overlapping 英文原文Given a circle represented as (radius, x_center, y_center) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-lef…
原文链接: https://leetcode-cn.com/problems/construct-k-palindrome-strings 英文原文Given a string s and an integer k. You should construct k non-empty palindrome strings using all the characters in s. Return True if you can use all the characters in s to cons…
原文链接: https://leetcode-cn.com/problems/check-if-there-is-a-valid-path-in-a-grid 英文原文Given a m x n grid. Each cell of the grid represents a street. The street of grid[i][j] can be: 1 which means a street connecting the left cell and the right cell. 2 …
原文链接: https://leetcode-cn.com/problems/count-number-of-teams 英文原文There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the following rules: Choose 3 soldiers …
原文链接: https://leetcode-cn.com/problems/design-underground-system 英文原文An underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average time it takes to travel from on…
原文链接: https://leetcode-cn.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k 英文原文Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times. T…
原文链接: https://leetcode-cn.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n 英文原文A happy string is a string that: consists only of letters of the set ['a', 'b', 'c']. s[i] != s[i + 1] for all values of i from 1 to s.length …
原文链接: https://leetcode-cn.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one 英文原文Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules: If the …
原文链接: https://leetcode-cn.com/problems/queries-on-a-permutation-with-key 英文原文Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: In the be…
原文链接: https://leetcode-cn.com/problems/html-entity-parser 英文原文HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself. The special characters and their entities fo…
原文链接: https://leetcode-cn.com/problems/check-if-a-string-can-break-another-string 英文原文Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can…
原文链接: https://leetcode-cn.com/problems/display-table-of-food-orders-in-a-restaurant 英文原文Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] w…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-frogs-croaking 英文原文You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multi…
原文链接: https://leetcode-cn.com/problems/maximum-points-you-can-obtain-from-cards 英文原文There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you ca…
原文链接: https://leetcode-cn.com/problems/diagonal-traverse-ii 英文原文Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images. Example 1: Input: nums = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,4,2,7,5…
原文链接: https://leetcode-cn.com/problems/max-difference-you-can-get-from-changing-an-integer 英文原文You are given an integer num. You will apply the following steps exactly two times: Pick a digit x (0 <= x <= 9). Pick another digit y (0 <= y <= 9). The d…
原文链接: https://leetcode-cn.com/problems/simplified-fractions 英文原文Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. The fractions can be in any order. Example…
原文链接: https://leetcode-cn.com/problems/count-good-nodes-in-binary-tree 英文原文Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in t…
原文链接: https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit 英文原文Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute diffe…
原文链接: https://leetcode-cn.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor 英文原文Given an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). Let's define a and b as follows: a = arr[…