随笔分类 -  Greedy

摘要:Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note: Exam 阅读全文
posted @ 2019-01-02 12:01 Veritas_des_Liberty 阅读(230) 评论(0) 推荐(0)
摘要:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l 阅读全文
posted @ 2019-01-02 11:27 Veritas_des_Liberty 阅读(191) 评论(0) 推荐(0)
摘要:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the pers 阅读全文
posted @ 2019-01-01 16:56 Veritas_des_Liberty 阅读(183) 评论(0) 推荐(0)
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2019-01-01 15:51 Veritas_des_Liberty 阅读(230) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2019-01-01 11:54 Veritas_des_Liberty 阅读(171) 评论(0) 推荐(0)
摘要:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for 阅读全文
posted @ 2019-01-01 11:13 Veritas_des_Liberty 阅读(166) 评论(0) 推荐(0)
摘要:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th 阅读全文
posted @ 2018-12-31 21:25 Veritas_des_Liberty 阅读(242) 评论(0) 推荐(0)
摘要:Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your 阅读全文
posted @ 2018-12-31 20:22 Veritas_des_Liberty 阅读(205) 评论(0) 推荐(0)
摘要:There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re 阅读全文
posted @ 2018-12-31 18:23 Veritas_des_Liberty 阅读(240) 评论(0) 推荐(0)
摘要: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 cost 阅读全文
posted @ 2018-12-31 16:46 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0)
摘要:There are N workers. The i-th worker has a quality[i] and a minimum wage expectation wage[i]. Now we want to hire exactly K workers to form a paid gro 阅读全文
posted @ 2018-12-24 22:26 Veritas_des_Liberty 阅读(310) 评论(0) 推荐(0)
摘要:You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subseq 阅读全文
posted @ 2018-12-21 17:59 Veritas_des_Liberty 阅读(228) 评论(0) 推荐(0)
摘要:Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g 阅读全文
posted @ 2018-12-01 17:17 Veritas_des_Liberty 阅读(175) 评论(0) 推荐(0)