摘要: 题目: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 爱做饭的小莹子 阅读(3311) 评论(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 爱做饭的小莹子 阅读(4026) 评论(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 爱做饭的小莹子 阅读(2493) 评论(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 爱做饭的小莹子 阅读(6206) 评论(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 爱做饭的小莹子 阅读(3435) 评论(0) 推荐(0) 编辑