原文链接: https://leetcode-cn.com/problems/minimum-difference-between-highest-and-lowest-of-k-scores 英文原文You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k. Pick the scores…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/count-number-of-pairs-with-absolute-difference-k 英文原文Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k. The value of |x| is defined as…
原文链接: https://leetcode-cn.com/problems/find-if-path-exists-in-graph 英文原文There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, whe…
原文链接: https://leetcode-cn.com/problems/count-special-quadruplets 英文原文Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that: nums[a] + nums[b] + nums[c] == nums[d], and a < b < c < d Example 1: Input: n…
原文链接: https://leetcode-cn.com/problems/reverse-prefix-of-word 英文原文Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character c…
原文链接: https://leetcode-cn.com/problems/convert-1d-array-into-2d-array 英文原文You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n column…
原文链接: https://leetcode-cn.com/problems/final-value-of-variable-after-performing-operations 英文原文There is a programming language with only four operations and one variable X: ++X and X++ increments the value of the variable X by 1. --X and X-- decremen…
原文链接: https://leetcode-cn.com/problems/maximum-difference-between-increasing-elements 英文原文Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and …
原文链接: https://leetcode-cn.com/problems/minimum-number-of-moves-to-seat-everyone 英文原文There are n seats and n students in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array stu…
原文链接: https://leetcode-cn.com/problems/minimum-moves-to-convert-string 英文原文You are given a string s consisting of n characters which are either 'X' or 'O'. A move is defined as selecting three consecutive characters of s and converting them to 'O'. N…
原文链接: https://leetcode-cn.com/problems/two-out-of-three 英文原文Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in a…
原文链接: 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-if-numbers-are-ascending-in-a-sentence 英文原文A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 wi…
原文链接: https://leetcode-cn.com/problems/number-of-valid-words-in-a-sentence 英文原文A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can …
原文链接: 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/smallest-index-with-equal-value 英文原文Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist. x mod y denotes the remainder when…
原文链接: https://leetcode-cn.com/problems/count-vowel-substrings-of-a-string 英文原文A substring is a contiguous (non-empty) sequence of characters within a string. A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') …
原文链接: 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/time-needed-to-buy-tickets 英文原文There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line. You are given a 0-indexed…
原文链接: https://leetcode-cn.com/problems/two-furthest-houses-with-different-colors 英文原文There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] …
原文链接: https://leetcode-cn.com/problems/find-target-indices-after-sorting-array 英文原文You are given a 0-indexed integer array nums and a target element target. A target index is an index i such that nums[i] == target. Return a list of the target indices…
原文链接: https://leetcode-cn.com/problems/deep-dark-fraction 中文题目有一个同学在学习分式。他需要将一个连分数化成最简分数,你能帮助他吗? 连分数是形如上图的分式。在本题中,所有系数都是大于等于0的整数。 输入的cont代表连分数的系数(cont[0]代表上图的a0,以此类推)。返回一个长度为2的数组[n, m],使得连分数的值等于n / m,且n, m最大公约数为1。 示例 1: 输入:cont = [3, 2, 0, 2] 输出:[13,…
原文链接: https://leetcode-cn.com/problems/guess-numbers 中文题目小A 和 小B 在玩猜数字。小B 每次从 1, 2, 3 中随机选择一个,小A 每次也从 1, 2, 3 中选择一个猜。他们一共进行三次这个游戏,请返回 小A 猜对了几次? 输入的guess数组为 小A 每次的猜测,answer数组为 小B 每次的选择。guess和answer的长度都等于3。 示例 1: 输入:guess = [1,2,3], answer = [1,2,3] 输出…
原文链接: https://leetcode-cn.com/problems/is-unique-lcci 英文原文Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? Example 1: Input: s = "leetcode" Output: false Example 2: Input: s…
原文链接: https://leetcode-cn.com/problems/check-permutation-lcci 英文原文Given two strings,write a method to decide if one is a permutation of the other. Example 1: Input: s1 = "abc", s2 = "bca" Output: true Example 2: Input: s1 = "abc", s2 = "bad" Output: …
原文链接: https://leetcode-cn.com/problems/string-to-url-lcci 英文原文Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters,and that you are given the "tr…
原文链接: https://leetcode-cn.com/problems/compress-string-lcci 英文原文Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string woul…
原文链接: https://leetcode-cn.com/problems/string-rotation-lcci 英文原文Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 (e.g.,"waterbottle" is a rotation of"erbottlewat"). Can you use only one call to the method that checks if one…
原文链接: https://leetcode-cn.com/problems/remove-duplicate-node-lcci 英文原文Write code to remove duplicates from an unsorted linked list. Example1: Input: [1, 2, 3, 3, 2, 1] Output: [1, 2, 3] Example2: Input: [1, 1, 1, 1, 2] Output: [1, 2] Note: The length…
原文链接: https://leetcode-cn.com/problems/palindrome-linked-list-lcci 英文原文Implement a function to check if a linked list is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) t…