摘要: 题目: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3, You should return the fol 阅读全文
posted @ 2015-04-17 23:47 YRB 阅读(287) 评论(0) 推荐(0)
摘要: 题目: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last 阅读全文
posted @ 2015-04-17 23:45 YRB 阅读(180) 评论(0) 推荐(0)
摘要: 题目: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were in 阅读全文
posted @ 2015-04-17 23:44 YRB 阅读(495) 评论(0) 推荐(0)
摘要: 题目: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your m 阅读全文
posted @ 2015-04-17 23:41 YRB 阅读(334) 评论(0) 推荐(0)
摘要: 题目: Given a matrix of m x n elements (m rows, ncolumns), return all elements of the matrix in spiral order. For example,Given the following matrix: Yo 阅读全文
posted @ 2015-04-17 23:40 YRB 阅读(485) 评论(0) 推荐(0)
摘要: 题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,− 阅读全文
posted @ 2015-04-17 23:39 YRB 阅读(782) 评论(0) 推荐(0)
摘要: 题目: Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. Show Tags Show Simila 阅读全文
posted @ 2015-04-17 23:38 YRB 阅读(439) 评论(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 阅读全文
posted @ 2015-04-17 23:37 YRB 阅读(728) 评论(0) 推荐(0)
摘要: 题目: Implement pow(x, n). 链接: http://leetcode.com/problems/powx-n/ 题解: 使用二分法求实数幂,假如不建立临时变量halfPow,直接return计算结果的话会超时,还没仔细研究为什么。 Time Complexity - O(logn 阅读全文
posted @ 2015-04-17 23:36 YRB 阅读(474) 评论(0) 推荐(0)
摘要: 题目: Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. Hide Tags Hash Table String Giv 阅读全文
posted @ 2015-04-17 23:32 YRB 阅读(348) 评论(0) 推荐(0)