原文链接: https://leetcode-cn.com/problems/find-original-array-from-doubled-array 英文原文An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulti…
标签详情
排序 分类
原文链接: https://leetcode-cn.com/problems/maximum-earnings-from-taxi 英文原文There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to po…
原文链接: https://leetcode-cn.com/problems/the-number-of-weak-characters-in-the-game 英文原文You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array pr…
原文链接: 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-operations-to-make-a-uni-value-grid 英文原文You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid. A uni-value grid is …
原文链接: https://leetcode-cn.com/problems/two-best-non-overlapping-events 英文原文You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at endTimei, and if you atte…
原文链接: https://leetcode-cn.com/problems/most-beautiful-item-for-each-query 英文原文You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively. You are also given a 0-indexed integer array…
原文链接: 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/find-all-people-with-secret 英文原文You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] ind…
原文链接: 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/pile-box-lcci 英文原文You have a stack of n boxes, with widths wi, depths di, and heights hi. The boxes cannot be rotated and can only be stacked on top of one another if each box in the stack is strictly larger tha…
原文链接: https://leetcode-cn.com/problems/smallest-difference-lcci 英文原文Given two arrays of integers, compute the pair of values (one value in each array) with the smallest (non-negative) difference. Return the difference. Example: Input: {1, 3, 15, 11, …
原文链接: https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof 中文题目找出数组中重复的数字。 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。 示例 1: 输入: [2, 3, 1, 0, 2, 5, 3] 输出:2 或 3 限制: 2 <= n <= 100000 通过…
原文链接: https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof 中文题目输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有奇数在数组的前半部分,所有偶数在数组的后半部分。 示例: 输入:nums = [1,2,3,4] 输出:[1,3,2,4] 注:[3,1,2,4] 也是正确的答案之一。 提示: 0 <= nums.length <= …
原文链接: https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof 中文题目输入整数数组 arr ,找出其中最小的 k 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。 示例 1: 输入:arr = [3,2,1], k = 2 输出:[1,2] 或者 [2,1] 示例 2: 输入:arr = [0,1,2,1], k = 1 输出:[0] 限制: 0 <= k <= arr.length <…
原文链接: 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/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof 中文题目输入一个非负整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。 示例 1: 输入: [10,2] 输出: "102" 示例 2: 输入: [3,30,34,5,9] 输出: "3033459" 提示: 0 < nums.length <= 100 说明: 输出结果可能非常大,所以你需要返回一个字符串…
原文链接: https://leetcode-cn.com/problems/bu-ke-pai-zhong-de-shun-zi-lcof 中文题目从若干副扑克牌中随机抽 5 张牌,判断是不是一个顺子,即这5张牌是不是连续的。2~10为数字本身,A为1,J为11,Q为12,K为13,而大、小王为 0 ,可以看成任意数字。A 不能视为 14。 示例 1: 输入: [1,2,3,4,5] 输出: True 示例 2: 输入: [0,0,1,2,5] 输出: True 限制: 数组长度为 5 数组的…
原文链接: https://leetcode-cn.com/problems/sub-sort-lcci 英文原文Given an array of integers, write a method to find indices m and n such that if you sorted elements m through n, the entire array would be sorted. Minimize n - m (that is, find the smallest suc…
原文链接: https://leetcode-cn.com/problems/sorted-merge-lcci 英文原文You are given two sorted arrays, A and B, where A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order. Initially the number of elements in A and…
原文链接: https://leetcode-cn.com/problems/peaks-and-valleys-lcci 英文原文In an array of integers, a "peak" is an element which is greater than or equal to the adjacent integers and a "valley" is an element which is less than or equal to the adjacent inte&sh…
原文链接: https://leetcode-cn.com/problems/smallest-k-lcci 英文原文Design an algorithm to find the smallest K numbers in an array. Example: Input: arr = [1,3,5,7,2,4,6,8], k = 4 Output: [1,2,3,4] Note: 0 <= len(arr) <= 100000 0 <= k <= min(100000, len(arr)) …
原文链接: https://leetcode-cn.com/problems/continuous-median-lcci 英文原文Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated. Median is the middle value in an ordered integ…
原文链接: https://leetcode-cn.com/problems/missing-number-lcci 英文原文An array contains all the integers from 0 to n, except for one number which is missing. Write code to find the missing integer. Can you do it in O(n) time? Note: This problem is slightly …
原文链接: https://leetcode-cn.com/problems/circus-tower-lcci 英文原文A circus is designing a tower routine consisting of people standing atop one anoth­er's shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than…
原文链接: 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/sum-swap-lcci 英文原文Given two arrays of integers, find a pair of values (one value from each array) that you can swap to give the two arrays the same sum. Return an array, where the first element is the element in…
原文链接: https://leetcode-cn.com/problems/ju-qing-hong-fa-shi-jian 英文原文 中文题目在战略游戏中,玩家往往需要发展自己的势力来触发各种新的剧情。一个势力的主要属性有三种,分别是文明等级(C),资源储备(R)以及人口数量(H)。在游戏开始时(第 0 天),三种属性的值均为 0。 随着游戏进程的进行,每一天玩家的三种属性都会对应增加,我们用一个二维数组 increase 来表示每天的增加情况。这个二维数组的每个元素是一个长度为 3 的一维…
原文链接: https://leetcode-cn.com/problems/zui-xiao-ju-xing-mian-ji 英文原文 中文题目二维平面上有 $N$ 条直线,形式为 `y = kx + b`,其中 `k`、`b`为整数 且 `k > 0`。所有直线以 `[k,b]` 的形式存于二维数组 `lines` 中,不存在重合的两条直线。两两直线之间可能存在一个交点,最多会有 $C_N^2$ 个交点。我们用一个平行于坐标轴的矩形覆盖所有的交点,请问这个矩形最小面积是多少。若直线之间无交点…