leetcode
文章平均质量分 53
记忆力不好
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode 34. Search for a Range
34. Search for a Range Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n).原创 2016-04-02 10:25:44 · 676 阅读 · 0 评论 -
leetcode 5. Longest Palindromic Substring 最长回文串
Longest Palindromic Substring Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substri原创 2016-04-13 22:02:28 · 730 阅读 · 0 评论 -
leetcode 59. Spiral Matrix II
59. Spiral Matrix II 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 following matrix: [ [ 1原创 2016-04-16 23:36:38 · 1085 阅读 · 0 评论 -
leetCode 41. First Missing Positive
41. First Missing Positive Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should ru原创 2016-03-27 22:04:31 · 727 阅读 · 0 评论 -
leetcode 287. Find the Duplicate Number,数组中找重复的数
287. Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that th原创 2016-03-27 21:09:43 · 2822 阅读 · 0 评论 -
【每天一道leetcode】1:N-Queens
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 all distinct solutions to the n-queens puzzle.原创 2016-06-25 16:20:42 · 899 阅读 · 0 评论 -
leetcode 300. Longest Increasing Subsequence 最长上升序列数
300. Longest Increasing Subsequence Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest incre原创 2016-04-02 15:28:50 · 1239 阅读 · 1 评论 -
leetcode 342. Power of Four 判断一个数是否为4的幂
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without原创 2016-04-23 17:22:01 · 3389 阅读 · 0 评论 -
leetcode 46,47. Permutations I/II 全排列问题 java
46.Permutations Total Accepted: 96713 Total Submissions: 271529 Difficulty: Medium Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following pe原创 2016-04-19 23:00:36 · 3754 阅读 · 2 评论 -
LeetCode 50. Pow(x, n),求幂算法
50. Pow(x, n) Implement pow(x, n). 这道题求x的n次幂,用二分法,时间复杂度logn,注意区分n public double myPow(double x, int n) { if(n==0) return 1.0; else if(n<0) return 1/pow(x,-原创 2016-03-27 16:24:26 · 1188 阅读 · 0 评论 -
leetcode 101. Symmetric Tree 判断对称树,递归和迭代
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the f原创 2016-04-30 21:23:13 · 2180 阅读 · 0 评论 -
leetcode 79. Word Search
Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or v原创 2016-04-11 21:19:40 · 936 阅读 · 0 评论 -
leetcode 231. Power of Two 判断是否为2的幂 Java
231. Power of Two Given an integer, write a function to determine if it is a power of two. Credits: Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.原创 2016-04-23 16:38:25 · 3367 阅读 · 0 评论 -
LeetCode 69. Sqrt(x),求根算法
69. Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. Subscribe to see which companies asked this question 这道题要找x的平方根,x的平方根肯定小于x/2。要在[1,x/2]有序序列当中找一个数,用二分法:原创 2016-03-27 15:28:01 · 2258 阅读 · 0 评论 -
leetCode 108. Convert Sorted Array to Binary Search Tree JAVA
108. Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 这到题把有序数组转成平衡二叉搜索树,所以选取数组的中点num[mid]作为根,对左右两边分原创 2016-04-03 14:29:49 · 1349 阅读 · 0 评论 -
Java 二叉树的前序、中序、后续遍历 递归和迭代实现
1.前序 递归 public List<Integer> preorderTraversal(TreeNode root) { List<Integer> list=new ArrayList<Integer>(); if(root!=null){ list.add(root.val); ...原创 2016-05-01 17:14:23 · 1368 阅读 · 1 评论
分享