天行健,君子以自强不息

守住心灵的宁静

Segment tree——线段树

线段树 一颗线段树的构造就是根据区间的性质的来构造的, 如下是一棵区间[0, 3]的线段树,每个[start, end]都是一个二叉树中的节点。 [0, 3]的线段树   区间划分大概就是上述的区间划分。可以看出每次都将区间的长度一分为二,数列长度为n,所以线段树的高度是log(n),...

2018-11-18 23:48:27

阅读数 34

评论数 0

【LeetCode】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: [ [&qu...

2018-11-18 23:35:15

阅读数 29

评论数 0

【LeetCode】Add and Search Word - Data structure design

Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word o...

2018-11-11 00:56:04

阅读数 25

评论数 0

【LeetCode】212. Word Search II

Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially ad...

2018-11-10 19:00:07

阅读数 22

评论数 0

【LeetCode】Partition List

Given 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 th...

2018-11-07 01:45:20

阅读数 25

评论数 0

【LeetCode】Word Search

Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where &...

2018-11-07 01:26:43

阅读数 27

评论数 0

【LeetCode】Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4],...

2018-11-07 01:17:24

阅读数 42

评论数 0

【LeetCode】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. Example 1: Input: [   [1,1,1],   [1,0,1],   [1,1,1]...

2018-11-07 00:17:32

阅读数 16

评论数 0

【LeetCode】Edit Distance

Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permi...

2018-11-07 00:10:37

阅读数 34

评论数 0

【LeetCode】Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted...

2018-11-07 00:00:08

阅读数 23

评论数 0

【LeetCode】Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted...

2018-11-06 23:54:01

阅读数 28

评论数 0

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