摘要: 题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r... 阅读全文
posted @ 2014-07-28 03:10 爱做饭的小莹子 阅读(3718) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't... 阅读全文
posted @ 2014-07-27 09:58 爱做饭的小莹子 阅读(2210) 评论(0) 推荐(0) 编辑
摘要: 题目: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... 阅读全文
posted @ 2014-07-27 09:49 爱做饭的小莹子 阅读(3313) 评论(0) 推荐(0) 编辑
摘要: 题目: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 e... 阅读全文
posted @ 2014-07-27 09:26 爱做饭的小莹子 阅读(1942) 评论(0) 推荐(0) 编辑
摘要: 题目:Divide two integers without using multiplication, division and mod operator.题解:这道题我自己没想出来。。。乘除取模都不让用。。那只有加减了。。。我参考的http://blog.csdn.net/perfect888... 阅读全文
posted @ 2014-07-27 09:12 爱做饭的小莹子 阅读(4027) 评论(2) 推荐(0) 编辑
摘要: 题目:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.题解:这道题跟NQueens的解法完全一样(具... 阅读全文
posted @ 2014-07-27 04:49 爱做饭的小莹子 阅读(2497) 评论(0) 推荐(0) 编辑
摘要: 题目:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return a... 阅读全文
posted @ 2014-07-27 04:36 爱做饭的小莹子 阅读(6208) 评论(1) 推荐(0) 编辑
摘要: 题目:Implement pow(x, n).题解:pow(x,n)就是求x的n次方。x的N次方可以看做:x^n = x^(n/2)*x^(n/2)*x^(n%2)。所以利用递归求解,当n==1的时候,x^n=x。当然n是可以小于0的,2^(-3) = 1/(2^3)。按照上面那个规律就可以解决了... 阅读全文
posted @ 2014-07-27 03:03 爱做饭的小莹子 阅读(6033) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtim... 阅读全文
posted @ 2014-07-27 00:57 爱做饭的小莹子 阅读(3436) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2014-07-26 23:47 爱做饭的小莹子 阅读(2811) 评论(0) 推荐(0) 编辑