摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2015-03-04 18:41 穆穆兔兔 阅读(157) 评论(0) 推荐(0)
摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.思路:和 N-queens 一样,不过只统计个数而言,... 阅读全文
posted @ 2015-03-04 16:54 穆穆兔兔 阅读(154) 评论(0) 推荐(0)
摘要: Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2015-03-04 16:05 穆穆兔兔 阅读(163) 评论(0) 推荐(0)
摘要: Implement pow(x,n).思路:可以连乘,但会超时,所以使用二分法:注意几点:1 不要写成pow(x, n/2)* pow(x, n/2) 还是会超时,因为还是会计算两遍,直接使用临时变量tmp= pow(x, n/2),然会return tmp*tmp2 注意int 有可能为负数3 注... 阅读全文
posted @ 2015-03-04 14:41 穆穆兔兔 阅读(207) 评论(0) 推荐(0)
摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.http://www.cnblogs.com/easonliu/p/364... 阅读全文
posted @ 2015-03-04 14:12 穆穆兔兔 阅读(217) 评论(0) 推荐(0)