- 博客(80)
- 收藏
- 关注
原创 leetcode-120 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5...
2019-05-31 17:17:07 113
原创 leetcode-119 Pascal's Triangle II
Given a non-negativeindexkwherek≤33, return thekthindex row of the Pascal's triangle.Note that the row index starts from0.In Pascal's triangle, each number is the sum of the two numbe...
2019-05-31 11:33:42 131
原创 leetcode-118 Pascal's Triangle
Given a non-negative integernumRows, generate the firstnumRowsof Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:...
2019-05-31 11:17:02 105
原创 leetcode-117 Populating Next Right Pointers in Each Node II
Given a binary treestruct Node { int val; Node *left; Node *right; Node *next;}Populate each next pointer to point to its next right node. If there is no next right node, the next point...
2019-05-31 08:58:45 152
原创 Java编程思想-笔记
一.哪些对象可以作为gc root:1.虚拟机栈中引用的对象2.方法区中常量引用的对象3.方法区中类静态属性引用的对象4.本地方法栈中JNI(即一般说的native方法)引用的对象什么是类静态属性(以及静态方法):首先静态属性和方法必须用static修饰符,static 可以修饰属性、方法、代码块、内部类静态属性(方法)和非静态属性(方法)的区别:一:内存中...
2019-05-30 22:12:55 996
原创 leetcode-116 Populating Next Right Pointers in Each Node
You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; ...
2019-05-30 21:32:20 132
原创 leetcode-115 Distinct Subsequences
Given a stringSand a stringT, count the number of distinct subsequences ofSwhich equalsT.A subsequence of a string is a new string which is formed from the original string by deleting some (ca...
2019-05-30 20:32:39 129
原创 leetcode-114 Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \ ...
2019-05-30 09:06:18 96
原创 leetcode-113 Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note:A leaf is a node with no children.Example:Given the below binary tree andsum = 22,...
2019-05-29 19:25:51 85
原创 leetcode-112 Path Sum
Given 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.Note:A leaf is a node with no children.Example:...
2019-05-28 20:29:59 113
原创 leetcode-111 Minimum Depth of Binary Tree
Given 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.Note:A leaf is a node with no childre...
2019-05-28 20:08:15 112
原创 leetcode-110 Balanced Binary Tree
Given 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 ofeverynode never diff...
2019-05-28 19:50:39 190
原创 leetcode-109 Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the ...
2019-05-28 17:32:31 131
原创 leetcode-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.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...
2019-05-28 16:38:32 89
原创 JAVA存储堆栈内存问题
Java基础中,通过new创建的对象存储在堆内存中,8大基本类型short,int,char,byte,boolean,float,double,long和对象的引用变量存储在栈内存中,那么具体是如何存储的? 栈:当在一段代码块定义一个变量时,Java就在栈中为这个变量分配内存空间,当该变量退出该作用域后,Java会自动释放掉为该变量所分配的内存空间,该内存空间可以立即被另作他用...
2019-05-27 20:25:53 338
原创 leetcode-107 Binary Tree Level Order Traversal II
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 example:Given binary tree[3,9,20,null,null,15,7...
2019-05-27 15:31:35 94
原创 leetcode-106 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.For example, giveninorder =[9,3,15,20,7]postorder = [9...
2019-05-27 15:02:13 129
原创 leetcode-105 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.For example, givenpreorder =[3,9,20,15,7]inorder = [9,3...
2019-05-27 12:18:00 77
原创 leetcode-104 Maximum Depth of Binary Tree
Given 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.Note:A leaf is a node with no childre...
2019-05-26 13:04:27 111
原创 leetcode-103 Binary Tree Zigzag Level Order Traversal
Given a binary tree, return thezigzag level ordertraversal 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...
2019-05-26 12:59:12 101
原创 leetcode-102 Binary Tree Level Order Traversal
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree[3,9,20,null,null,15,7], 3 / \ 9 20 ...
2019-05-24 17:13:59 170
原创 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[1,2,2,3,4,4,3]is symmetric: 1 / \ 2 2 / \ / \3 4 4 3...
2019-05-24 13:57:01 107
原创 leetcode-100 Same Tree
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example ...
2019-05-24 10:32:22 113
原创 leetcode-99 Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Example 1:Input: [1,3,null,null,2] 1 /3 \ 2Output: [3,1,null,nul...
2019-05-24 10:21:50 133
原创 leetcode-98 Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key. The ...
2019-05-23 17:50:32 121
原创 leetcode-97 Interleaving String
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.Example 1:Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Output: trueExample 2:Input: s1 = "aabcc", s2 = "...
2019-05-23 16:26:31 129
原创 leetcode-96 Unique Binary Search Trees
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: 1 ...
2019-05-23 14:56:51 97
原创 leetcode-95 Unique Binary Search Trees II
Given an integern, generate all structurally uniqueBST's(binary search trees) that store values 1 ...n.Example:Input: 3Output:[ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3...
2019-05-22 20:39:56 137
原创 leetcode-94 Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Follow up:Recursive solution is trivial, could y...
2019-05-22 16:41:49 82
原创 leetcode-93 Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: "25525511135"Output: ["255.255.11.135", "255.255.111.35"]class Solutio...
2019-05-22 16:22:35 117
原创 leetcode-92 Reverse Linked List II
Reverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5-...
2019-05-21 20:18:55 116
原创 leetcode-91 Decode Ways
A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only digits, determine t...
2019-05-20 22:27:28 76
原创 leetcode-90
Given a collection of integers that might contain duplicates,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: [1,2,2]...
2019-05-20 17:37:00 178
原创 leetcode-89 Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gr...
2019-05-20 11:06:49 100
原创 leetcode-88 Merge Sorted Array
Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:The number of elements initialized innums1andnums2aremandnrespectively. You may assume tha...
2019-05-20 10:12:43 83
原创 leetcode-87 Scramble String
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ gr ...
2019-05-20 08:58:09 103
原创 leetcode-86 Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of t...
2019-05-17 16:07:39 86
原创 leetcode-85 Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.Example:Input:[ ["1","0","1","0","0"], ["1","0","1","1","1"], ["1","1",...
2019-05-16 23:05:53 76
原创 leetcode-84 Largest Rectangle in Histogram
Givennnon-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 ea...
2019-05-16 21:57:56 75
原创 leetcode-83 Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output: 1-...
2019-05-16 20:19:50 52
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人