随笔分类 - leetcode
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN...
阅读全文
摘要:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa...
阅读全文
摘要:http://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/Given a binary tree struct TreeLinkNode { TreeLinkNode *left; ...
阅读全文
摘要:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?F...
阅读全文
摘要:Binary Tree Inorder TraversalTotal Accepted:16406Total Submissions:47212My SubmissionsGiven a binary tree, return theinordertraversal of its nodes' va...
阅读全文
摘要:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fir...
阅读全文
摘要:http://oj.leetcode.com/problems/reverse-integer/public class Solution { public int reverse(int x) { String strX = Integer.toString(x); ...
阅读全文
摘要:http://oj.leetcode.com/problems/same-tree/public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { Stack pstack = new...
阅读全文
摘要:http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/public class Solution { public int maxDepth(TreeNode root) { if(root!=null){ ...
阅读全文
摘要:http://oj.leetcode.com/problems/minimum-path-sum/public class Solution { public int minPathSum(int[][] grid) { int row = grid.length; ...
阅读全文
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw...
阅读全文
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
阅读全文
摘要:Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that i...
阅读全文
摘要:http://oj.leetcode.com/problems/search-for-a-range/使用快速排序的原理进行查找public class Solution { public int[] searchRange(int[] A, int target) { in...
阅读全文

浙公网安备 33010602011771号