自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Set Matrix Zeroes

Given a m  n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space? A straight forward solution using O(mn) space is probably a bad idea

2014-08-29 17:09:20 575

原创 Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of g

2014-08-29 16:55:30 401

原创 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? 思路。 f(n)表示爬到n层楼梯的

2014-08-29 16:54:04 464

原创 Plus One

Given a number represented as an array of digits, plus one to the number.

2014-08-29 16:53:45 278

原创 Rotate Image

You are given an n  n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? 分析: 先按照对角线

2014-08-29 16:52:12 410

原创 Trapping Rain Water

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], r

2014-08-29 15:57:00 392

原创 Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules http://sudoku.com.au/TheRules.aspx . The Sudoku board could be partially filled, where empty cells are filled with the charac

2014-08-28 17:00:41 489

原创 Next Permutation

初阶。 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 poss

2014-08-28 16:39:52 425

原创 Two Sum

初阶。 Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target,

2014-08-26 16:37:29 446

原创 Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4

2014-08-26 10:03:38 592

原创 二进制中包含1的数量

#include using namespace std; int func(int x) { int count = 0; while(x) { count ++; x=x&(x-1); } return count; } int main() { cout<< func(15) << endl; return 0; }结果是4.

2014-08-25 22:51:27 548

原创 Median of Two Sorted Arrays

There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log(m + n)). 思路。 1)

2014-08-25 17:17:53 521

原创 Search in Rotated Sorted Array

初阶。 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

2014-08-25 16:47:27 429

原创 Remove Duplicates from Sorted Array

描述 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place w

2014-08-25 15:59:42 436

转载 Visual Studio控制台程序输出窗口一闪而过的解决方法

刚接触 Visual Studio的时候大多数人会写个Hello World的程序试一下,有的人会发现执行结束后输出窗口会一闪而过,并没有出现Press any key to continue的字样。无论是在Visual Studio 2008、2010还是2012中都有这种情况出现,有些人可能会用下面两种方法中的一种:     在程序代码的最后加上system("pause")或者ge

2014-08-24 14:05:59 734

空空如也

空空如也

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

TA关注的人

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