原文链接: https://leetcode-cn.com/problems/k-th-smallest-prime-fraction 英文原文You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k. For every i and j where 0 <= i…
标签详情
数组 分类
原文链接: https://leetcode-cn.com/problems/escape-the-ghosts 英文原文You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget] that you are trying to ge…
原文链接: 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/smallest-rotation-with-highest-score 英文原文You are given an array nums. You can rotate it by a non-negative integer k so that the array becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], .…
原文链接: https://leetcode-cn.com/problems/design-hashset 英文原文Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class: void add(key) Inserts the value key into the HashSet. bool contains(key) Returns whether the value …
原文链接: https://leetcode-cn.com/problems/design-hashmap 英文原文Design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map. void put(int key, int value) inserts a (k…
原文链接: https://leetcode-cn.com/problems/bricks-falling-when-hit 英文原文You are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space. A brick is stable if: It is directly connected to the top of the grid, or At least…
原文链接: https://leetcode-cn.com/problems/split-array-with-same-average 英文原文You are given an integer array nums. You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B). Retur…
原文链接: https://leetcode-cn.com/problems/unique-morse-code-words 英文原文International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' maps to "-...", 'c' maps to "-.-.", …
原文链接: https://leetcode-cn.com/problems/number-of-lines-to-write-string 英文原文You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width …
原文链接: 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/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/chalkboard-xor-game 英文原文You are given an array of integers nums represents the numbers written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first.…
原文链接: 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/bus-routes 英文原文You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in…
原文链接: 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/shortest-distance-to-a-character 英文原文Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the clos…
原文链接: 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/making-a-large-island 英文原文You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4…
原文链接: 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/flipping-an-image 英文原文Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. …
原文链接: 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/guess-the-word 英文原文This is an interactive problem. You are given an array of unique strings wordlist where wordlist[i] is 6 letters long, and one word in this list is chosen as secret. You may call Master.guess(…
原文链接: 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 …