原文链接: https://leetcode-cn.com/problems/last-stone-weight 英文原文You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash th…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/remove-all-adjacent-duplicates-in-string 英文原文You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeat…
原文链接: https://leetcode-cn.com/problems/greatest-common-divisor-of-strings 英文原文For two strings s and t, we say "t divides s" if and only if s = t + ... + t (t concatenated with itself 1 or more times) Given two strings str1 and str2, return the larges…
原文链接: https://leetcode-cn.com/problems/occurrences-after-bigram 英文原文Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after …
原文链接: https://leetcode-cn.com/problems/duplicate-zeros 英文原文Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not wri…
原文链接: https://leetcode-cn.com/problems/distribute-candies-to-people 英文原文We distribute some number of candies, to a row of n = num_people people in the following way: We then give 1 candy to the first person, 2 candies to the second person, and so on …
原文链接: https://leetcode-cn.com/problems/print-in-order 英文原文Suppose we have a class: public class Foo { public void first() { print("first"); } public void second() { print("second"); } public void third() { print("third"); } } The same instance of Foo…
原文链接: https://leetcode-cn.com/problems/defanging-an-ip-address 英文原文Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". Example 1: Input: address = "1.1.1.1" Output…
原文链接: https://leetcode-cn.com/problems/mean-of-array-after-removing-some-elements 英文原文Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements. Answers within 10-5 of the …
原文链接: https://leetcode-cn.com/problems/relative-sort-array 英文原文Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 ar…
原文链接: https://leetcode-cn.com/problems/element-appearing-more-than-25-in-sorted-array 英文原文Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer. Exa…
原文链接: https://leetcode-cn.com/problems/number-of-equivalent-domino-pairs 英文原文Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino …
原文链接: https://leetcode-cn.com/problems/replace-elements-with-greatest-element-on-right-side 英文原文Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. A…
原文链接: https://leetcode-cn.com/problems/n-th-tribonacci-number 英文原文The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. Example 1: Input: n = 4 Output: 4 Exp…
原文链接: https://leetcode-cn.com/problems/decompress-run-length-encoded-list 英文原文We are given a list nums of integers representing a list compressed with run-length encoding. Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]]…
原文链接: https://leetcode-cn.com/problems/rank-transform-of-an-array 英文原文Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Rank is an integer starting from…
原文链接: https://leetcode-cn.com/problems/day-of-the-year 英文原文Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year. Example 1: Input: date = "2019-01-09" Output: 9 Explanation: Given date …
原文链接: https://leetcode-cn.com/problems/maximum-number-of-words-you-can-type 英文原文There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words separated by a single sp…
原文链接: https://leetcode-cn.com/problems/number-of-days-between-two-dates 英文原文Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. Example 1: Input: date…
原文链接: https://leetcode-cn.com/problems/prime-arrangements 英文原文Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it is greater than 1, and cannot be writ…
原文链接: https://leetcode-cn.com/problems/distance-between-bus-stops 英文原文A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops numbe…
原文链接: https://leetcode-cn.com/problems/day-of-the-week 英文原文Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the day, month and year respectively. Return the answer as one of the f…
原文链接: https://leetcode-cn.com/problems/three-consecutive-odds 英文原文Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. Example 1: Input: arr = [2,6,4,1] Output: false Explanation: T…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-balloons 英文原文Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in text at most once. Return the…
原文链接: https://leetcode-cn.com/problems/reformat-department-table 英文原文Table: Department +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | revenue | int | | month | varchar | +-------------+---------+ (id, month)…
原文链接: https://leetcode-cn.com/problems/delete-characters-to-make-fancy-string 英文原文A fancy string is a string where no three consecutive characters are equal. Given a string s, delete the minimum possible number of characters from s to make it fancy. …
原文链接: https://leetcode-cn.com/problems/unique-number-of-occurrences 英文原文Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise. Example 1: Input: arr = [1,2,2,1,1,3] Output: t…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-move-chips-to-the-same-position 英文原文We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the position…
原文链接: https://leetcode-cn.com/problems/split-a-string-in-balanced-strings 英文原文Balanced strings are those that have an equal quantity of 'L' and 'R' characters. Given a balanced string s, split it in the maximum amount of balanced strings. Return the …
原文链接: https://leetcode-cn.com/problems/cells-with-odd-values-in-a-matrix 英文原文There is an m x n matrix that is initialized to all 0's. There is also a 2D array indices where each indices[i] = [ri, ci] represents a 0-indexed location to perform some in…