自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 Redundant Connection II

In this problem, a rooted tree is adirectedgraph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one p...

2018-12-24 07:58:00 207

转载 Redundant Connection

In this problem, a tree is anundirectedgraph that is connected and has no cycles. The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), with one a...

2018-12-24 06:58:00 112

转载 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 \ 2 Output: [...

2018-12-20 10:11:00 130

转载 Min Stack

   Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. ...

2018-12-09 06:31:00 100

转载 *Flatten Binary Tree to Linked List

REFERENCE: https://blog.csdn.net/fuxuemingzhu/article/details/70241424 Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ ...

2018-12-06 10:01:00 53

转载 Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. 算法1:我们在构建新链表的节点时,保存原始链表的...

2018-12-03 11:49:00 54

转载 Binary Tree Maximum Path Sum

Given anon-emptybinary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child conn...

2018-12-02 09:44:00 66

转载 Arithmetic Slices

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, these are arithmetic sequ...

2018-12-02 01:29:00 72

转载 Integer to English Words

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231- 1. Example 1: Input: 123 Output: "One Hundred Twenty Three" Example 2: I...

2018-11-30 08:03:00 76

转载 Unique Email Addresses

Every email consists of a local name and a domain name, separated by the @ sign. For example, [email protected],aliceis the local name, andleetcode.comis the domain name. Besides lowerc...

2018-11-30 02:05:00 268

转载 Stone Game

Alex and Lee play a game with piles of stones. There are an even number ofpilesarranged in a row, and each pile has a positive integer number of stonespiles[i]. The objective of the game is ...

2018-11-26 05:20:00 60

转载 Two Sum IV - Input is a BST

Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: 5 / \ 3 6...

2018-10-17 09:42:00 81

转载 Insert into a Binary Search Tree

   Given the root node of a binary search tree (BST) and a value to be inserted into the tree,insert the value into the BST. Return the root node of the BST after the insertion. It is guarantee...

2018-10-15 05:19:00 99

转载 Subtree of Another Tree

Given two non-empty binary treessandt, check whether treethas exactly the same structure and node values with a subtree ofs. A subtree ofsis a tree consists of a node insand all of this...

2018-10-15 05:00:00 79

转载 Leaf-Similar Trees

Consider all the leaves of a binary tree. Fromleft to right order, the values of thoseleaves form aleaf value sequence. For example, in the given tree above, the leaf value sequenc...

2018-10-15 03:38:00 74

转载 Diameter of Binary Tree

   Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongestpath between any two nodes in a tree. This path may...

2018-10-15 03:26:00 63

转载 Counting Bits

Given a non negative integer numbernum. For every numbersiin the range0 ≤ i ≤ numcalculate the number of 1's in their binary representation and return them as an array. Example 1: Input: 2...

2018-10-09 00:12:00 104

转载 Paint Fence

There is a fence with n posts, each post can be painted with one of the k colors. You have to paint all the posts such that no more than two adjacent fence posts have the same color. Return the...

2018-10-08 23:34:00 155

转载 JAVA 中各种数据结构

先来个图: 引自: https://www.geeksforgeeks.org/deque-interface-java-example/    转载于:https://www.cnblogs.com/hygeia/p/9753304.html

2018-10-08 11:21:00 62

转载 sliding window模板解法

Among all leetcode questions, I find that there are at least 5 substring search problem which could be solved by the sliding window algorithm. template: public class Solution { public Li...

2017-02-28 06:24:00 179

转载 Find All Anagrams in a String

Given a stringsand anon-emptystringp, find all the start indices ofp's anagrams ins. Strings consists of lowercase English letters only and the length of both stringssandpwill not be ...

2017-02-28 06:18:00 78

转载 **Binary Tree Postorder Traversal

Given a binary tree, return thepostordertraversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[3,2,1]. 牛解法:postorder就是L-R-...

2016-10-06 01:42:00 56

转载 *Binary Tree Preorder Traversal

题目: Given a binary tree, return thepreordertraversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[1,2,3]. Note:Recursive so...

2016-10-06 01:39:00 48

转载 *Binary Tree Inorder Traversal

题目: Given a binary tree, return theinordertraversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[1,3,2]. Note:Recursive soluti...

2016-10-06 01:35:00 41

转载 First Unique Character in a String

Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. N...

2016-08-30 02:25:00 36

转载 回溯法模板

1、概念 回溯算法实际上一个类似枚举的搜索尝试过程,主要是在搜索尝试过程中寻找问题的解,当发现已不满足求解条件时,就“回溯”返回,尝试别的路径。 回溯法是一种选优搜索法,按选优条件向前搜索,以达到目标。但当探索到某一步时,发现原先选择并不优或达不到目标,就退回一步重新选择,这种走不通就退回再走的技术为回溯法,而满足回溯条件的某个状态的点称为“回溯点”。 ...

2016-08-27 01:17:00 92

转载 *Linked List Random Node

Given a singly linked list, return a random node's value from the linked list. Each node must have thesame probabilityof being chosen. Follow up:What if the linked list is extremely large and ...

2016-08-26 03:11:00 49

转载 *Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it...

2016-08-16 10:39:00 44

转载 *Maximum Product of Word Lengths

Given a string arraywords, find the maximum value oflength(word[i]) * length(word[j])where the two words do not share common letters. You may assume that each word will contain only lower case...

2016-08-16 10:03:00 44

转载 Flatten 2D Vector

Implement an iterator to flatten a 2d vector. For example,Given 2d vector = [ [1,2], [3], [4,5,6] ] By callingnextrepeatedly untilhasNextreturns false, the order of elements...

2016-08-16 07:27:00 100

转载 Valid Perfect Square

Given a positive integernum, write a function which returns True ifnumis a perfect square else False. Note:Do notuse any built-in library function such assqrt. Example 1: Input: 16 Retu...

2016-08-16 04:39:00 41

转载 Ransom Note

Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 all 
the 
magazines,
 write 
a 
function 
that 
will 
return 
true 
if 
the 
ransom 
 note 
can 
be 
co...

2016-08-14 01:37:00 2700

转载 *Top K Frequent Elements

Given a non-empty array of integers, return thekmost frequent elements. For example,Given[1,1,1,2,2,3]and k = 2, return[1,2]. Note: You may assumekis always valid, 1 ≤k≤ number o...

2016-08-11 06:38:00 74

转载 Count Numbers with Unique Digits

Given anon-negativeinteger n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < ...

2016-08-10 12:45:00 132

转载 *Zigzag Iterator

Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: v1 = [1, 2] v2 = [3, 4, 5, 6] By callingnextrepeatedly untilhasNex...

2016-08-10 11:10:00 54

转载 Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. [分析]首先别忘了什么是factorial,就是阶乘。那么很容易想到需要统计(2,5)对的个数,因为2×5=10。但是这个条件放...

2016-08-10 10:54:00 45

转载 *Single Number III

这题真特么是太难了 解题思路 首先我们先把原数组全部异或起来,那么我们会得到一个数字,这个数字是两个不相同的数字异或的结果,我们取出其中任意一位为‘1’的位,为了方便起见,我们用 a &= -a 来取出最右端为‘1’的位。。。这道题的巧妙之处在于利用x1 ^ x2的结果对原数组进行了分组,进而将x1和x2分开了。具体方法则是利用了x1 ^ x2不为0的特性,如果x...

2016-08-10 10:41:00 47

转载 Sum of Two Integers

Calculate the sum of two integersaandb, but you arenot allowedto use the operator+and-. Example:Givena= 1 andb= 2, return 3. Credits:Special thanks to@fujiaozhufor adding this pro...

2016-08-10 04:09:00 50

转载 *Perfect Squares & DP 自底向上 & 自顶向下

Given a positive integern, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum ton. For example, givenn=12, return3because12 = 4 + 4 + 4; givenn=...

2016-08-09 06:58:00 63

转载 Missing Ranges

Given a sorted integer array where the range of elements are [lower,upper] inclusive, return its missing ranges. For example, given[0, 1, 3, 50, 75],lower= 0 andupper= 99, return["2", "4-...

2016-08-06 11:57:00 43

空空如也

空空如也

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

TA关注的人

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