自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 收藏
  • 关注

原创 135. Candy

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 requirements:Each child must have at least one candy.

2017-06-08 14:25:12 204

原创 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 permitted to complete at most one transaction (ie, buy one and sell one share of the stock), des

2017-06-06 13:28:15 170

原创 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?Note: Given n will be a positive int

2017-06-03 16:19:54 153

原创 134. Gas Station

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 costs cost[i] of gas to travel from station i to its ne

2017-05-18 15:05:09 210

原创 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 an

2017-05-17 15:37:53 113

原创 64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at

2017-05-09 17:16:11 192

原创 62. Unique Paths

A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bott

2017-05-09 16:14:50 130

原创 文章标题

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position.Determine if you ar

2017-04-27 14:14:05 147

原创 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 always

2017-04-19 14:10:17 124

原创 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 th

2017-04-17 15:35:19 147

原创 Valid Parentheses

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are all valid but

2017-04-15 16:03:41 123

原创 Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head. For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list b

2017-04-14 14:03:29 130

原创 Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. 题目考察深度优先遍历,给出了DFS算法c

2017-04-05 14:42:19 698

原创 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. For example, given array S = [-1, 0, 1, 2,

2017-03-29 14:59:38 260

原创 Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.本题题意描述不太清楚 找出所有字符串的公共最大前缀,就有一组字符串,它们都有共同的前缀。 class Solution { public: string longestCommonPrefix(vector<string>

2017-03-28 15:09:41 282

原创 Container With Most Water

Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lin

2017-03-27 17:00:42 139

原创 Palindrome Number

Palindrome Number

2017-03-20 16:27:02 153

原创 Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Note: The input is assumed to be a 32-bit signed integer. Your functi

2017-03-13 15:14:51 166

原创 ZigZag Conversion

c++

2017-03-08 15:15:23 147

原创 Median of Two Sorted Arrays

c++

2017-03-03 16:43:15 182

原创 Longest Substring Without Repeating Characters

1. 类似贪心算法,两个指针i指向子串的结尾,j指向子串的开始。 2. 当发现i指向的下一个字符在子串中出现时,j指向子串中该字符的下一个字符。class Solution { public: int lengthOfLongestSubstring(string s) { unordered_map<char,int> sub;//sub记录遍历过程中每个字符最后出现的位

2017-02-28 16:11:29 155

原创 Add Two Numbers

You may assume the two numbers do not contain any leading zero, except the number 0 itself. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 - 本题为两个单向链表相加,头节点为个位,以后以此递推。 - 输出为一个链表,为两个链表相加的和。 从

2017-02-25 14:07:43 135

原创 Two Sum

- 这道题目是给定一个数组和一个特定的整数,如果数组里的两项相加结果为所给特定整数,则输出这两项的index. - 例如num=[2,7,11,15],特定整数为9,则2+7=9。输出为[1,2]。 - 所使用的unordered_map关联容器采用哈希表结构,例如hash[123],既number123所对应的index。 - 具体思路如下代码和注释。class Solution { pub

2017-02-25 13:59:28 147

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除