- 博客(5)
- 收藏
- 关注
原创 [LeetCode]050-Pow(x,n)
题目: Implement pow(x, n). 实现x的n次幂Solution: 类似于二分的方法来优化“x*x*…x“。 要注意的是当n = INT_MIN时,反过来-n会越界,这时候需要pow(x,INT_MIN) * x 即可。代码如下:class Solution {public: double myPow(double x, int n) {
2016-05-07 19:23:11 662
原创 [LeetCode]049-Group Anagrams
题目: Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“bat”] ]Note:For the re
2016-05-07 16:40:26 555
原创 [LeetCode]048-Rotate Image
题目: You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up: Could you do this in-place?Solution: 其实就是矩阵的旋转,找到规律即可,比较简单,代码如下:class Solution {publ
2016-05-07 16:06:40 425
原创 [LeetCode]047-Permutations II
题目: Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1].
2016-05-07 14:54:13 1073
原创 [LeetCode]046-Permutations
题目:Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. Solutions:
2016-05-06 22:35:08 1312
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人