自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Pow(x, n) -- leetcode

Implement pow(x, n).算法思路:利用二分法。此算法在leetcode上实际执行时间为8ms。class Solution {public: double pow(double x, int n) { if (!n) return 1; if (n>0) { const

2015-01-31 19:30:11 523

原创 Anagrams -- leetcode

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.算法思路:将单词进行排序。用map统计排序后相等的出现次数。将次数大于1的单词放入结果集。第1次出现时,因次数最终是否大于1不明郎,将其暂存入

2015-01-31 12:47:19 512

原创 Rotate Image -- leetcode

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?根据一个点坐标计算出其他三个点的位置。可以依据,每个点到外边框的对应距离相等,推算坐标。

2015-01-28 11:18:10 487

原创 Permutations II -- leetcode

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].

2015-01-25 17:41:08 451

原创 Permutations -- leetcode

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].全排列,从全体元素中挑一个

2015-01-24 16:17:29 582

原创 Jump Game II -- leetcode

class Solution {public: int jump(int A[], int n) { int step = 0; int far = 0, last = 0; for (int i=0; far < n-1; ++i) { far = max(far, A[i]+i);

2015-01-23 17:02:50 406

原创 Jump Game -- leetcode

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 i

2015-01-22 14:23:07 591

原创 Wildcard Matching -- leetcode

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t

2015-01-21 11:49:09 484

原创 Multiply Strings -- leetcode

Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.用字符串表示的整数,做乘法运算。如人工做乘法运算的步骤一样,实现了本算

2015-01-18 21:27:02 454

原创 Trapping Rain Water -- leetcode

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]

2015-01-18 16:53:12 575

原创 First Missing Positive -- leetcode

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant

2015-01-18 15:10:37 694

原创 Combination Sum II -- leetcode

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina

2015-01-16 15:37:29 513

原创 Combination Sum -- leetcode

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb

2015-01-15 17:09:53 551

原创 Count and Say -- leetcode

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as 

2015-01-15 11:36:57 497

原创 Search Insert Position -- leetcode

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.

2015-01-11 21:18:07 419

原创 Search for a Range -- leetcode

Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found in

2015-01-11 19:01:12 403

原创 Search in Rotated Sorted Array -- leetcode

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its

2015-01-10 20:19:23 411

原创 Longest Valid Parentheses -- leetcode

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which

2015-01-10 17:21:17 470

原创 Next Permutation -- leetcode

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o

2015-01-09 11:32:09 485

原创 Substring with Concatenation of All Words -- leetcode

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an

2015-01-03 16:28:29 692

空空如也

空空如也

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

TA关注的人

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