原文链接: https://leetcode-cn.com/problems/valid-tic-tac-toe-state 英文原文Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game. The board is a…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/number-of-subarrays-with-bounded-maximum 英文原文Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in t…
原文链接: https://leetcode-cn.com/problems/all-paths-from-source-to-target 英文原文Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order. The graph is given as …
原文链接: https://leetcode-cn.com/problems/champagne-tower 英文原文We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row. Each glass holds one cup of champagne. Then, some champagne is pou…
原文链接: https://leetcode-cn.com/problems/find-eventual-safe-states 英文原文There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nod…
原文链接: https://leetcode-cn.com/problems/max-increase-to-keep-city-skyline 英文原文There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n integer matrix gri…
原文链接: https://leetcode-cn.com/problems/soup-servings 英文原文There are two types of soup: type A and type B. Initially, we have n ml of each type of soup. There are four kinds of operations: Serve 100 ml of soup A and 0 ml of soup B, Serve 75 ml of soup …
原文链接: https://leetcode-cn.com/problems/expressive-words 英文原文Sometimes people repeat letters to represent extra feeling. For example: "hello" -> "heeellooo" "hi" -> "hiiii" In these strings like "heeellooo", we have groups of adjacent letters that are…
原文链接: https://leetcode-cn.com/problems/subdomain-visit-count 英文原文A website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and at the lowest level, "discuss.leet…
原文链接: https://leetcode-cn.com/problems/largest-sum-of-averages 英文原文You are given an integer array nums and an integer k. You can partition the array into at most k non-empty adjacent subarrays. The score of a partition is the sum of the averages of e…
原文链接: https://leetcode-cn.com/problems/binary-tree-pruning 英文原文Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is…
原文链接: https://leetcode-cn.com/problems/ambiguous-coordinates 英文原文We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s. For example, "(1, 3)" becomes…
原文链接: https://leetcode-cn.com/problems/linked-list-components 英文原文You are given the head of a linked list containing unique integer values and an integer array nums that is a subset of the linked list values. Return the number of connected components…
原文链接: https://leetcode-cn.com/problems/design-linked-list 英文原文Design your implementation of the linked list. You can choose to use a singly or doubly linked list. A node in a singly linked list should have two attributes: val and next. val is the val…
原文链接: https://leetcode-cn.com/problems/short-encoding-of-words 英文原文A valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference string s ends with the '#' charact…
原文链接: https://leetcode-cn.com/problems/binary-trees-with-factors 英文原文Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1. We make a binary tree using these integers, and each number may be used for any number …
原文链接: https://leetcode-cn.com/problems/friends-of-appropriate-ages 英文原文There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person. A Person x will not send a friend request to a perso…
原文链接: https://leetcode-cn.com/problems/most-profit-assigning-work 英文原文You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where: difficulty[i] and profit[i] are the difficulty and the profit of the ith job, and w…
原文链接: https://leetcode-cn.com/problems/masking-personal-information 英文原文You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules. Email address…
原文链接: https://leetcode-cn.com/problems/design-circular-queue 英文原文Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and th…
原文链接: https://leetcode-cn.com/problems/find-and-replace-in-string 英文原文You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and…
原文链接: https://leetcode-cn.com/problems/image-overlap 英文原文You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values. We translate one image however we choose by sliding …
原文链接: https://leetcode-cn.com/problems/new-21-game 英文原文Alice plays the following game, loosely based on the card game "21". Alice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number o…
原文链接: https://leetcode-cn.com/problems/push-dominoes 英文原文There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second,…
原文链接: https://leetcode-cn.com/problems/keys-and-rooms 英文原文There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. W…
原文链接: https://leetcode-cn.com/problems/split-array-into-fibonacci-sequence 英文原文You are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequence is a list f …
原文链接: https://leetcode-cn.com/problems/longest-mountain-in-array 英文原文You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < .…
原文链接: https://leetcode-cn.com/problems/hand-of-straights 英文原文Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards. Given an integer array …
原文链接: https://leetcode-cn.com/problems/shifting-letters 英文原文You are given a string s of lowercase English letters and an integer array shifts of the same length. Call the shift() of a letter, the next letter in the alphabet, (wrapping around so that …
原文链接: https://leetcode-cn.com/problems/maximize-distance-to-closest-person 英文原文You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (…