2015年5月5日

摘要: 1 Subset https://leetcode.com/problems/subsets/ Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must b 阅读全文
posted @ 2015-05-05 14:56 月下之风 阅读(162) 评论(0) 推荐(0) 编辑

2015年5月4日

摘要: Title:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r... 阅读全文
posted @ 2015-05-04 09:27 月下之风 阅读(189) 评论(0) 推荐(0) 编辑

2015年5月2日

摘要: Title: http://poj.org/problem?id=2533 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric 阅读全文
posted @ 2015-05-02 20:54 月下之风 阅读(310) 评论(0) 推荐(0) 编辑
摘要: 1 以前以为memset是给一个数组赋初值,实际上呢?void *memset(void *s, int ch, unsigned n);将s所指向的某一块内存中的每个字节的内容全部设置为ch指定的ASCII值,块的大小由第三个参数指定,这个函数通常为新申请的内存做初始化工作,其返回值为指向S的指针... 阅读全文
posted @ 2015-05-02 20:21 月下之风 阅读(199) 评论(0) 推荐(0) 编辑
摘要: Title: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) Yo 阅读全文
posted @ 2015-05-02 13:55 月下之风 阅读(175) 评论(0) 推荐(0) 编辑

2015年5月1日

摘要: Title: 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 阅读全文
posted @ 2015-05-01 10:08 月下之风 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Title: Implement int sqrt(int x). Compute and return the square root of x. 思路:这个平方根肯定是在【1,x】之间,所以在这个区间使用二分查找。需要注意的是,代码中一直使用mid ,x/mid来比较,因为如果使用mid的平法, 阅读全文
posted @ 2015-05-01 10:03 月下之风 阅读(182) 评论(0) 推荐(0) 编辑

2015年4月30日

摘要: Title: https://leetcode.com/problems/unique-paths/ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). Th 阅读全文
posted @ 2015-04-30 11:03 月下之风 阅读(192) 评论(0) 推荐(0) 编辑

2015年4月29日

摘要: Title: https://leetcode.com/problems/powx-n/ 思路:二分。使用递归或者非递归。非递归有点难理解.pow(0,0)=1 递归的方法是将n为负数的用除法解决。有问题,没有考虑0的负数次幂会导致除数为0.对于非递归,可以这么理解,x是指数,不断增长,x , x^ 阅读全文
posted @ 2015-04-29 09:47 月下之风 阅读(180) 评论(0) 推荐(0) 编辑

2015年4月28日

摘要: Title: A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, dete 阅读全文
posted @ 2015-04-28 15:20 月下之风 阅读(148) 评论(0) 推荐(0) 编辑

导航