原文链接: https://leetcode-cn.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid 英文原文There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [s…
标签详情
贪心 分类
原文链接: 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/removing-minimum-and-maximum-from-array 英文原文You are given a 0-indexed array of distinct integers nums. There is an element in nums that has the lowest value and an element that has the highest value. We call the…
原文链接: 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/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/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/you-le-yuan-de-mi-gong 英文原文 中文题目小王来到了游乐园,她玩的第一个项目是模拟推销员。有一个二维平面地图,其中散布着 N 个推销点,编号 0 到 N-1,不存在三点共线的情况。每两点之间有一条直线相连。游戏没有规定起点和终点,但限定了每次转角的方向。首先,小王需要先选择两个点分别作为起点和终点,然后从起点开始访问剩余 N-2 个点恰好一次并回到终点。访问的顺序需要满足一串给定的长度为 N-2 …
原文链接: 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$ 个交点。我们用一个平行于坐标轴的矩形覆盖所有的交点,请问这个矩形最小面积是多少。若直线之间无交点…
原文链接: https://leetcode-cn.com/problems/t3fKg1 英文原文 中文题目某实验室计算机待处理任务以 `[start,end,period]` 格式记于二维数组 `tasks`,表示完成该任务的时间范围为起始时间 `start` 至结束时间 `end` 之间,需要计算机投入 `period` 的时长,注意: 1. `period` 可为不连续时间 2. 首尾时间均包含在内 处于开机状态的计算机可同时处理任意多个任务,请返回电脑最少开机多久,可处理完所有任务。 …
原文链接: https://leetcode-cn.com/problems/o8SXZn 英文原文 中文题目给定 N 个无限容量且初始均空的水缸,每个水缸配有一个水桶用来打水,第 `i` 个水缸配备的水桶容量记作 `bucket[i]`。小扣有以下两种操作: - 升级水桶:选择任意一个水桶,使其容量增加为 `bucket[i]+1` - 蓄水:将全部水桶接满水,倒入各自对应的水缸 每个水缸对应最低蓄水量记作 vat[i],返回小扣至少需要多少次操作可以完成所有水缸蓄水要求。 注意:实际蓄水量 …
原文链接: https://leetcode-cn.com/problems/WqXACV 英文原文 中文题目有 `N` 位扣友参加了微软与力扣举办了「以扣会友」线下活动。主办方提供了 `2*N` 道题目,整型数组 `questions` 中每个数字对应了每道题目所涉及的知识点类型。 若每位扣友选择不同的一题,请返回被选的 `N` 道题目至少包含多少种知识点类型。 示例 1: 输入:questions = [2,1,6,2] 输出:1 解释:有 2 位扣友在 4 道题目中选择 2 题。可选择完成…
原文链接: https://leetcode-cn.com/problems/RQku0D 中文题目给定一个非空字符串 s,请判断如果 最多 从字符串中删除一个字符能否得到一个回文字符串。 示例 1: 输入: s = "aba" 输出: true 示例 2: 输入: s = "abca" 输出: true 解释: 可以删除 "c" 字符 或者 "b" 字符 示例 3: 输入: s = "abc" 输出: false 提示: 1 <= s.length <= 105 s 由小写英文字母组成 注意:…
原文链接: https://leetcode-cn.com/problems/uOAnQW 英文原文 中文题目「力扣挑战赛」心算项目的挑战比赛中,要求选手从 `N` 张卡牌中选出 `cnt` 张卡牌,若这 `cnt` 张卡牌数字总和为偶数,则选手成绩「有效」且得分为 `cnt` 张卡牌数字总和。 给定数组 `cards` 和 `cnt`,其中 `cards[i]` 表示第 `i` 张卡牌上的数字。 请帮参赛选手计算最大的有效得分。若不存在获取有效得分的卡牌方案,则返回 0。 示例 1: 输入:c…
上一页
6 / 6