- 博客(18)
- 收藏
- 关注
原创 649. Dota2 Senate
内容: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 wants to make a decision about a change in the D
2018-01-19 05:28:16 369
原创 738. Monotone Increasing Digits
内容: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 monotone increasing digits if and only if each pa
2018-01-19 05:28:08 222
原创 621. Task Scheduler
内容:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task coul
2018-01-19 05:28:01 1889
原创 133. Clone Graph
内容:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each node,
2018-01-19 05:27:46 181
原创 310. Minimum Height Trees
内容:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called m
2018-01-19 05:27:38 271
原创 53. Maximum Subarray
内容:Find 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,2,1] has t
2018-01-19 05:27:29 835
原创 169. Majority Element
内容:Given 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 element alw
2018-01-19 05:27:16 201
原创 690. Employee Importance
内容:You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id.For example, employee 1 is the leader of employe
2018-01-19 05:26:54 349
原创 392. Is Subsequence
内容:Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string
2018-01-18 14:28:05 1714
原创 435. Non-overlapping Intervals
内容:Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.思路:这个题目与《算法导论》中活动安排的题目非常类似。活动选择问题有n个需要在同一天使用同一个教室的活动a1,a2,
2018-01-18 14:25:57 174
原创 763. Partition Labels
内容: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 part, and return a list of integers representing
2018-01-18 14:23:44 155
原创 122. Best Time to Buy and Sell Stock II
内容: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 complete as many transactions as you like (ie, buy one
2018-01-18 14:19:03 216
原创 455. Assign Cookies
内容: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 greed factor gi, which is the minimum size of a
2018-01-18 14:16:54 3833
原创 198. House Robber
内容:You 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 adjacent ho
2018-01-18 14:14:23 605
原创 70. Climbing Stairs
内容:You 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?思路:这个题目是一个计算n层阶梯情况下,走到顶端的路径种数(要求每
2018-01-18 14:11:57 174
原创 53. Maximum Subarray
内容:Find 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,2,1] has t
2018-01-18 14:09:00 2157
原创 303. Range Sum Query - Immutable
内容:Given an integer array nums, find the sum of the elementsclass NumArray {public: NumArray(vector &nums) { arr = nums; } int sumRange(int i, int j) { int sum = 0;
2018-01-18 14:05:20 142
原创 746. Min Cost Climbing Stairs
内容:On 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 the top of
2018-01-18 13:59:38 1074
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人