- 博客(19)
- 收藏
- 关注
原创 期末报告
2018"百度之星"程序设计大赛题目1调查问卷度度熊为了完成毕业论文,需要收集一些数据来支撑他的论据,于是设计了一份包含 m 个问题的调查问卷,每个问题只有 ‘A’ 和 ‘B’ 两种选项。 将问卷散发出去之后,度度熊收到了 n 份互不相同的问卷,在整理结果的时候,他发现可以只保留其中的一部分问题,使得这 n 份问卷仍然是互不相同的。这里认为两张问卷是不同的,当且仅当存在至少一个被保留的问题在...
2018-12-19 15:08:38
223
原创 Leetcode Algorithms - Dynamic Programming:650. 2 Keys Keyboard
DescriptionInitially on a notepad only one character ‘A’ is present. You can perform two operations on this notepad for each step:Copy All: You can copy all the characters present on the notepad (p...
2018-12-14 14:43:41
77
原创 Leetcode Algorithms - Dynamic Programming:486. Predict the Winner
DescriptionGiven an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a pl...
2018-12-14 14:41:31
65
原创 Leetcode Algorithms - Dynamic Programming:357. Count Numbers with Unique Digits
DescriptionGiven a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ ...
2018-11-21 09:37:48
68
原创 Leetcode Algorithms - Dynamic Programming:343. Integer Break
DescriptionGiven a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n...
2018-11-21 09:36:12
69
原创 Leetcode Algorithms - Dynamic Programming:646. Maximum Length of Pair Chain
DescriptionYou are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b <...
2018-11-21 09:34:18
97
原创 Leetcode Algorithms - Dynamic Programming:413. Arithmetic Slices
DescriptionA sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmeti...
2018-11-21 09:31:01
60
原创 Leetcode Algorithms - Dynamic Programming:647. Palindromic Substrings
DescriptionGiven a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even th...
2018-11-20 20:04:44
50
原创 Leetcode Algorithms - Dynamic Programming:338. Counting Bits
DescriptionGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example:For n...
2018-11-20 20:03:17
60
原创 Leetcode Algorithms - Divide and Conquer:169. Majority Element
DescriptionGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority e...
2018-11-20 20:02:03
83
原创 Leetcode Algorithms - Greedy:455. Assign Cookies
DescriptionAssume 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 greed factor gi, which is the minimum s...
2018-11-20 20:00:13
57
原创 Leetcode Algorithms - Greedy:122. Best Time to Buy and Sell Stock II
DescriptionSay 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 complete as many transactions as you like (i...
2018-11-20 19:58:48
56
原创 Leetcode Algorithms - Dynamic Programming:303. Range Sum Query - Immutable
DescriptionGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) ->...
2018-11-20 19:57:07
64
原创 Leetcode Algorithms - Dynamic Programming:198. House Robber
DescriptionYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that ad...
2018-11-20 19:55:30
90
原创 Leetcode Algorithms - Dynamic Programming:121. Best Time to Buy and Sell Stock
DescriptionSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of th...
2018-11-20 19:52:31
61
原创 Leetcode Algorithms - Dynamic Programming:70. Climbing Stairs
DescriptionYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be ...
2018-11-20 19:50:38
68
原创 Leetcode Algorithms - Dynamic Programming:746. Min Cost Climbing Stairs
DescriptionOn a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach ...
2018-11-20 19:48:55
105
原创 Leetcode Algorithms - Divide and Conquer : 53. Maximum Subarray
DescriptionFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1...
2018-09-23 15:16:27
137
原创 Leetcode Algorithms : 2. Add Two Numbers
DescriptionYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers ...
2018-09-23 15:13:10
65
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人