- 浏览: 201185 次
- 性别:
- 来自: 杭州
最新评论
-
hthhit:
...
回溯算法之N皇后问题(java实现) -
huntfor:
249326109 写道这个算法的复杂度有考虑过么O(n^2) ...
[leetcode]Longest Valid Parentheses -
249326109:
这个算法的复杂度有考虑过么
[leetcode]Longest Valid Parentheses -
huntfor:
249326109 写道又搜到你的了 你怎么搜的,为啥我搜不到 ...
[leetcode]Sort Colors -
249326109:
又搜到你的了
[leetcode]Sort Colors
文章列表
新博文地址:
[leetcode]Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.
跟这道题没有任何区别。
pu ...
新博文地址:
[leetcode]Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.
根据前序遍历和中序遍历构建二叉树,构建 ...
新博文地址:
[leetcode]Binary Tree Zigzag Level Order Traversal
Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tre ...
新博文地址:[leetcode]Palindrome Partitioning
新代码要简洁一点。。。。
Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b"], [ ...
新博文地址:[leetcode]Subsets II
Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,If S = [1,2,2], a solution is:[ [2], [1] ...
这个算法写的太烂,大家直接看新博文,地址:
[leetcode]Flatten Binary Tree to Linked List
Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2 \ 3 \ ...
新博文地址:[leetcode]Longest Consecutive Sequence
Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.Your ...
Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.
Search in Rotated Sorted Array的进化,考虑了有重复数字的情况,在 Search ...
新博文地址:[leetcode]Sum Root to Leaf Numbers
Sum Root to Leaf Numbers
写道
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of all root-to-lea ...
新博文地址:[leetcode]Search in Rotated Sorted Array
Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index, otherwise re ...
新博文地址:[leetcode]Populating Next Right Pointers in Each Node II
Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only u ...
新博文地址:[leetcode]Sort Colors
Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respe ...
新博文地址:[leetcode]Rotate Image
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?
我没有想到in-place的方法,因此开辟了O(n^2)的空间,显然是不满足的要求的。
...
java中的值传递、引用传递以及数组传递小结
- 博客分类:
- 语言基础
当我们在学习第一门编程语言C语言的时候,对这样一个交换函数印象比较深刻
void swap(int a,int b){
int tem = a;
a = b;
b = tem;
}
当我们调用这个方法时候,发现调用之后的结果并没有达到a、b值互换的效果。这也是我 ...
新博文地址:[leetcode]Set Matrix Zeroes
新博文中,用了四种算法,时间复杂度都是O(m*n),空间复杂度分别为O(m*n),O(m+n)、O(n)、O(1),FYI
Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution usi ...