原文链接: https://leetcode-cn.com/problems/number-of-good-pairs 英文原文Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. Example 1: Input: nums = [1,2,3,1,1,3] Output: 4 Explanati…
标签详情
计数 分类
原文链接: https://leetcode-cn.com/problems/design-parking-system 英文原文Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the ParkingSy…
原文链接: https://leetcode-cn.com/problems/maximum-population-year 英文原文You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person. The population of some year x is the number of peopl…
原文链接: https://leetcode-cn.com/problems/largest-color-value-in-a-directed-graph 英文原文There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1. You are given a string colors where colors[i] is a lowercase English …
原文链接: https://leetcode-cn.com/problems/substrings-of-size-three-with-distinct-characters 英文原文A string is good if there are no repeated characters. Given a string s, return the number of good substrings of length three in s. Note that if th…
原文链接: https://leetcode-cn.com/problems/redistribute-characters-to-make-all-strings-equal 英文原文You are given an array of strings words (0-indexed). In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any …
原文链接: https://leetcode-cn.com/problems/check-if-all-characters-have-equal-number-of-occurrences 英文原文Given a string s, return true if s is a good string, or false otherwise. A string s is good if all the characters that appear in s have the same numbe…
原文链接: https://leetcode-cn.com/problems/number-of-pairs-of-interchangeable-rectangles 英文原文You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the it…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-ways-to-partition-an-array 英文原文You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions: 1 <= p…
原文链接: https://leetcode-cn.com/problems/detect-squares 英文原文You are given a stream of points on the X-Y plane. Design an algorithm that: Adds new points from the stream into a data structure. Duplicate points are allowed and should be treated as differ…
原文链接: https://leetcode-cn.com/problems/longest-subsequence-repeated-k-times 英文原文You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s. A subsequence is a string that can be…
原文链接: https://leetcode-cn.com/problems/stone-game-ix 英文原文Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the it…
原文链接: https://leetcode-cn.com/problems/kth-distinct-string-in-an-array 英文原文A distinct string is a string that is present only once in an array. Given an array of strings arr, and an integer k, return the kth distinct string present in arr. If there a…
原文链接: https://leetcode-cn.com/problems/check-whether-two-strings-are-almost-equivalent 英文原文Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 …
原文链接: https://leetcode-cn.com/problems/count-common-words-with-one-occurrence 英文原文Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays. Example 1: Input: words1 = ["leetcode","is",…
原文链接: https://leetcode-cn.com/problems/tic-tac-toe-lcci 英文原文Design an algorithm to figure out if someone has won a game of tic-tac-toe. Input is a string array of size N x N, including characters " ", "X" and "O", where " " represents a empty grid. T…
原文链接: https://leetcode-cn.com/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof 中文题目数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 示例 1: 输入: [1, 2, 3, 2, 2, 2, 5, 4, 2] 输出: 2 限制: 1 <= 数组长度 <= 50000 注意:本题与主站 169 题相同:ht…
原文链接: https://leetcode-cn.com/problems/di-yi-ge-zhi-chu-xian-yi-ci-de-zi-fu-lcof 中文题目在字符串 s 中找出第一个只出现一次的字符。如果没有,返回一个单空格。 s 只包含小写字母。 示例 1: 输入:s = "abaccdeff" 输出:'b' 示例 2: 输入:s = "" 输出:' ' 限制: 0 <= s 的长度 <= 50000 通过代码 高赞题解本题考察 哈希表 的使用,本文介绍 哈希表 和 有序哈希表 …
原文链接: https://leetcode-cn.com/problems/living-people-lcci 英文原文Given a list of people with their birth and death years, implement a method to compute the year with the most number of people alive. You may assume that all people were born between 1900 …
原文链接: https://leetcode-cn.com/problems/master-mind-lcci 英文原文The Game of Master Mind is played as follows: The computer has four slots, and each slot will contain a ball that is red (R). yellow (Y). green (G) or blue (B). For example, the computer mig…
原文链接: https://leetcode-cn.com/problems/baby-names-lcci 英文原文Each year, the government releases a list of the 10000 most common baby names and their frequencies (the number of babies with that name). The only problem with this is that some names have m…
原文链接: https://leetcode-cn.com/problems/find-majority-element-lcci 英文原文A majority element is an element that makes up more than half of the items in an array. Given a integers array, find the majority element. If there is no majority element, return -…
原文链接: https://leetcode-cn.com/problems/pairs-with-sum-lcci 英文原文Design an algorithm to find all pairs of integers within an array which sum to a specified value. Example 1: Input: nums = [5,6,5], target = 11 Output: [[5,6]] Example 2: Input: nums = [5…
原文链接: https://leetcode-cn.com/problems/g5c51o 中文题目给定一个整数数组 nums 和一个整数 k ,请返回其中出现频率前 k 高的元素。可以按 任意顺序 返回答案。 示例 1: 输入: nums = [1,1,1,2,2,3], k = 2 输出: [1,2] 示例 2: 输入: nums = [1], k = 1 输出: [1] 提示: 1 <= nums.length <= 105 k 的取值范围是 [1, 数组中不相同的元素的个数] 题目数据保…
原文链接: https://leetcode-cn.com/problems/0jQkd0 英文原文 中文题目在 「力扣挑战赛」 开幕式的压轴节目 「无人机方阵」中,每一架无人机展示一种灯光颜色。 无人机方阵通过两种操作进行颜色图案变换: - 调整无人机的位置布局 - 切换无人机展示的灯光颜色 给定两个大小均为 N*M 的二维数组 source 和 target 表示无人机方阵表演的两种颜色图案,由于无人机切换灯光颜色的耗能很大,请返回从 source 到 target 最少需要多少架无人机切换…
上一页
2 / 2