题目描述:
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on ...
最后更新于 .
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on ...
最后更新于 .
让我们通过考虑下面的问题来理解线段树。
给定一个数组arr[0 . . . n-1]
,我们要对数组执行这样的操作:
1 计算从下标l到r的元素之和,其中 0 <= l <= r <= n-1
2 修改数组指定元素的值arr[i] = x,其中 0 <= i <= n-1
一个简单的方案是从l
到r
执行循环,计算给定区间的元素之和。更新值的时候,简单地令arr[i] = x。第一个操作花费O(n)的时间,第二个操作花费O ...
最后更新于 .
The string "PAYPALISHIRING"
is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N A P L S ...
最后更新于 .
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
OJ's undirected graph serialization:
Nodes are labeled uniquely.
We use #
as a separator for each node, and ,
as a separator for ...
最后更新于 .
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].
You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from ...