自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(78)
  • 收藏
  • 关注

原创 Leetcode 85. Maximal Rectangle

QuestionGiven a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.Code public int maximalRectangle(char[][] matrix) { if (matrix == nu

2016-04-10 21:10:11 318

原创 leetcode 84. Largest Rectangle in Histogram

QuestionGiven n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of e

2016-04-10 20:28:44 311

原创 Leetcode 86. Partition List

QuestionGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each

2016-04-06 13:38:53 517

原创 Leetcode 87. Scramble String

QuestionGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”: great / \ gr

2016-04-06 13:31:44 294

原创 Leetcode 89. Gray Code

QuestionThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence

2016-04-06 10:37:14 428

原创 Leetcode 99. Recover Binary Search Tree

QuestionTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Code TreeNode pre = null; TreeNode first = null; TreeNode second = null

2016-04-05 19:19:17 233

原创 Leetcode 96. Unique Binary Search Trees

QuestionGiven n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s. 1 3 3 2 1 \

2016-04-05 19:10:51 507

原创 Leetcode 95. Unique Binary Search Trees II

QuestionGiven n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should return all 5 unique BST’s shown below. 1 3

2016-04-05 19:08:54 438

原创 leetcode 94. Binary Tree Inorder Traversal

QuestionGiven a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Code public void get(TreeNode root, Li

2016-04-05 18:45:55 217

原创 Leetcode 93. Restore IP Addresses

QuestionGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given “25525511135”,return [“255.255.11.135”, “255.255.111.35”]. (Order d

2016-04-05 18:43:43 219

原创 Leetcode 92. Reverse Linked List II

QuestionReverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the foll

2016-04-05 18:15:49 289

原创 leetcode 91. Decode Ways

QuestionA message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the total n

2016-04-05 16:40:58 390

原创 Leetcode 90. Subsets II

QuestionGiven a collection of integers that might contain duplicates, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain d

2016-04-05 16:13:05 204

原创 Leetcode 78. Subsets

QuestionGiven a set of distinct integers, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For examp

2016-04-05 15:51:16 224

原创 Leetcode 72. Edit Distance

QuestionGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a wo

2016-03-31 21:46:31 418

原创 Leetcode 100. Same Tree

QuestionGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.Code public

2016-03-29 15:02:42 222

原创 Leetcode 101. Symmetric Tree

QuestionGiven 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 3But the following

2016-03-29 15:00:16 202

原创 Leetcode 102. Binary Tree Level Order Traversal

QuestionGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 /

2016-03-29 14:57:32 240

原创 Leetcode 103. Binary Tree Zigzag Level Order Traversal

QuestionGiven 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 bina

2016-03-29 14:56:08 343

原创 Leetcode 104. Maximum Depth of Binary Tree

QuestionGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Code递归方式 /** * 递归的方式 *

2016-03-29 14:53:38 387

原创 Leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal

QuestionGiven preorder and inorder traversal of a tree, construct the binary tree.Code public TreeNode get(int[] preorder, int[] inorder, int i, int ileft, int iright) { if (ileft > iright) {

2016-03-29 14:44:56 232

原创 Leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal

QuestonGiven inorder and postorder traversal of a tree, construct the binary tree.Code public TreeNode get(int[] inorder, int[] postorder, int i, int ileft, int iright) { if (ileft > iright) {

2016-03-29 14:40:49 228

原创 Leetcode 107. Binary Tree Level Order Traversal II

QuestionGiven a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example: Given binary tree {3,9,20,#,#,15,7

2016-03-29 14:30:42 261

原创 Leetcode 108. Convert Sorted Array to Binary Search Tree

QuestionGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.Code public TreeNode build(int[] nums, int left, int right) { if (left <= right) {

2016-03-29 14:26:46 253

原创 Leetcode 109. Convert Sorted List to Binary Search Tree

QuestionGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Codepublic TreeNode build(List<Integer> nums, int left, int right) { if (lef

2016-03-29 14:25:24 395

原创 Leetcode 28. Implement strStr()

QuestionImplement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Code public int strStr(String haystack, String needle) { if (h

2016-03-29 14:14:06 180

原创 Leetcode 110. Balanced Binary Tree

QuestionGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never di

2016-03-28 21:42:05 235

原创 Leetcode 111. Minimum Depth of Binary Tree My Submissions QuestionEditorial Solution

QuestionGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Code队列的方式 /** * 队列的方式实现 *

2016-03-28 20:22:29 628

原创 leetcode 113. Path Sum II

QuestionGiven a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22, 5 / \

2016-03-28 20:10:35 246

原创 Leetcode 112. Path Sum

QuestionGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example: Given the below binary tree and

2016-03-28 20:09:20 172

原创 Leetcode 114. Flatten Binary Tree to Linked List

QuestionGiven 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 \

2016-03-28 20:01:23 169

转载 JVM指令集

JVM指令集(指令码、助记符、功能描述)指令码助记符功能描述0x00nop无操作 0x01aconst_null 指令格式:  aconst_null 功能描述:  null进栈。

2016-03-28 18:23:19 226

原创 JVM字节码格式

字节码格式字节码是JVM的机器语言。JVM加载类文件时,对类中的每个方法,它都会得到一个字节码流。这些字节码流保存在JVM的方法区中。在程序运行过程中,当一个方法被调用时,它的字节码流就会被执行。根据特定JVM设计者的选择,它们可以通过解释的方式,即时编译(Just-in-time compilation)的方式或其他技术的方式被执行。方法的字节码流就是JVM的指令(instruction)序列。每

2016-03-27 12:59:44 930

原创 java中多态的经典问题分析

Questionpackage demo;/** * Created by zwj on 2016/3/26. */class A { public String show(D obj) { return ("A and D"); } public String show(A obj) { return ("A and A"); }

2016-03-26 20:14:33 2098

原创 JVM相关知识

JVM内存堆布局图解分析JVM运行原理及Stack和Heap的实现过程JVM垃圾回收机制入门深入理解JVM之内存区域与内存溢出Java虚拟机内存优化实践Java虚拟机体系结构深入研究总结JVM性能优化入门指南JVM中锁优化简介

2016-03-26 11:26:50 429

原创 leetcode 123. Best Time to Buy and Sell Stock III

QuestionSay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Codepublic int m

2016-03-25 21:51:23 176

原创 Leetcode 122. Best Time to Buy and Sell Stock II

QuestionSay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy

2016-03-25 21:49:22 169

原创 Leetcode 121. Best Time to Buy and Sell Stock

questionSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stoc

2016-03-25 21:46:54 185

原创 Leetcode 117. Populating Next Right Pointers in Each Node II

QuestionFollow 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 use constant extra

2016-03-25 21:37:27 252

原创 Leetcode 116. Populating Next Right Pointers in Each Node

QuestionGiven a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next rig

2016-03-25 21:29:04 224

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除