随笔分类 - Greedy
发表于 2019-03-11 16:38阅读:191评论:0推荐:0
摘要: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
阅读全文 »
发表于 2019-02-16 20:51阅读:295评论: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
阅读全文 »
发表于 2019-01-26 21:26阅读:266评论: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
阅读全文 »
发表于 2019-01-26 21:18阅读:244评论: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
阅读全文 »
发表于 2019-01-26 21:16阅读:187评论: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
阅读全文 »
发表于 2019-01-24 12:42阅读:283评论: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
阅读全文 »
发表于 2019-01-24 11:29阅读:230评论: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
阅读全文 »
发表于 2019-01-23 22:56阅读:210评论: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
阅读全文 »
发表于 2019-01-22 20:19阅读:188评论: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
阅读全文 »
发表于 2019-01-22 19:18阅读:207评论: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
阅读全文 »
发表于 2019-01-22 19:01阅读:342评论: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
阅读全文 »
发表于 2019-01-22 17:57阅读:310评论: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
阅读全文 »
发表于 2019-01-10 20:55阅读:264评论: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
阅读全文 »
发表于 2019-01-09 22:36阅读:359评论: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
阅读全文 »
发表于 2019-01-09 21:05阅读:232评论: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
阅读全文 »
发表于 2019-01-05 22:35阅读:261评论: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
阅读全文 »
发表于 2019-01-05 21:50阅读:337评论: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
阅读全文 »
发表于 2019-01-05 17:52阅读:322评论: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
阅读全文 »
发表于 2019-01-03 10:06阅读:247评论: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
阅读全文 »
发表于 2019-01-02 22:10阅读:231评论: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
阅读全文 »