随笔分类 -  Greedy

摘要:Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c 阅读全文 »
posted @ 2019-03-11 16:38 Veritas_des_Liberty 阅读(191) 评论(0) 推荐(0) 编辑
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文 »
posted @ 2019-02-16 20:51 Veritas_des_Liberty 阅读(295) 评论(0) 推荐(0) 编辑
摘要:Given an array A of 0s and 1s, divide the array into 3 non-empty parts such that all of these parts represent the same binary value. If it is possible 阅读全文 »
posted @ 2019-01-26 21:26 Veritas_des_Liberty 阅读(266) 评论(0) 推荐(0) 编辑
摘要:Given an array A of integers, for each integer A[i] we need to choose either x = -K or x = K, and add x to A[i] (only once). After this process, we ha 阅读全文 »
posted @ 2019-01-26 21:18 Veritas_des_Liberty 阅读(244) 评论(0) 推荐(0) 编辑
摘要:Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting paren 阅读全文 »
posted @ 2019-01-26 21:16 Veritas_des_Liberty 阅读(187) 评论(0) 推荐(0) 编辑
摘要:You want to form a target string of lowercase letters. At the beginning, your sequence is target.length '?' marks. You also have a stamp of lowercase 阅读全文 »
posted @ 2019-01-24 12:42 Veritas_des_Liberty 阅读(283) 评论(0) 推荐(0) 编辑
摘要: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, provided 阅读全文 »
posted @ 2019-01-24 11:29 Veritas_des_Liberty 阅读(230) 评论(0) 推荐(0) 编辑
摘要:Given two arrays A and B of equal size, the advantage of A with respect to B is the number of indices i for which A[i] > B[i]. Return any permutation 阅读全文 »
posted @ 2019-01-23 22:56 Veritas_des_Liberty 阅读(210) 评论(0) 推荐(0) 编辑
摘要:We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row or column, and toggling each value in that row or c 阅读全文 »
posted @ 2019-01-22 20:19 Veritas_des_Liberty 阅读(188) 评论(0) 推荐(0) 编辑
摘要:At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bil 阅读全文 »
posted @ 2019-01-22 19:18 Veritas_des_Liberty 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequen 阅读全文 »
posted @ 2019-01-22 19:01 Veritas_des_Liberty 阅读(342) 评论(0) 推荐(0) 编辑
摘要:N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side b 阅读全文 »
posted @ 2019-01-22 17:57 Veritas_des_Liberty 阅读(310) 评论(0) 推荐(0) 编辑
摘要:A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one p 阅读全文 »
posted @ 2019-01-10 20:55 Veritas_des_Liberty 阅读(264) 评论(0) 推荐(0) 编辑
摘要:An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a and b. Find the minimum size of a set S 阅读全文 »
posted @ 2019-01-09 22:36 Veritas_des_Liberty 阅读(359) 评论(0) 推荐(0) 编辑
摘要:Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has m 阅读全文 »
posted @ 2019-01-09 21:05 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0) 编辑
摘要:121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte 阅读全文 »
posted @ 2019-01-05 22:35 Veritas_des_Liberty 阅读(261) 评论(0) 推荐(0) 编辑
摘要:In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators coming from two parties. Now the senate 阅读全文 »
posted @ 2019-01-05 21:50 Veritas_des_Liberty 阅读(337) 评论(0) 推荐(0) 编辑
摘要:There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dth day. A course should be ta 阅读全文 »
posted @ 2019-01-05 17:52 Veritas_des_Liberty 阅读(322) 评论(0) 推荐(0) 编辑
摘要:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks coul 阅读全文 »
posted @ 2019-01-03 10:06 Veritas_des_Liberty 阅读(247) 评论(0) 推荐(0) 编辑
摘要:There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the hor 阅读全文 »
posted @ 2019-01-02 22:10 Veritas_des_Liberty 阅读(231) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示