随笔分类 - Greedy
贪心算法
[Leetcode 452] 最少需要射出多少支箭Minimum Number of Arrows to Burst Balloons 贪心 重载
摘要:【题目】 There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of th
阅读全文
[Leetcode 134]汽车加油站 Gas Station (环形)
摘要:【题目】 There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it
阅读全文
[Leetcode 392]判断子序列 Is Subsequence
摘要:【思路】 判断s是否为t的子串,所以length(s)<=length(t)。于是两个指针,一次循环。 将s、t转换为数组p1、p2。 i为过程中s的匹配长度。 i=0空串,单独讨论返回true。 当i=p1.length-1时返回true,否则循环结束返回false。 【代码】 【举例】
阅读全文
[Leetcode 376]摇摆序列 Wiggle Subsequence
摘要:【题目】 A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative.
阅读全文
[Leetcode 881]船救人 Boats to Save People 贪心
摘要:【题目】 The i-th person has weight people[i], and each boat can carry a maximum weight of limit. Each boat carries at most 2 people at the same time, pro
阅读全文
[Leetcode 55]跳格子JumpGame
摘要:【题目】 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your
阅读全文
浙公网安备 33010602011771号