Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/algorithmzuo/algorithm-journey
/ subtreeAdd
Method
subtreeAdd
src/class161/Code01_HLD1.java:254–256 ·
view source on GitHub ↗
(int x, int v)
Source
from the content-addressed store, hash-verified
252
253
// x的子树上,所有节点的值增加v
254
public
static
void
subtreeAdd(
int
x,
int
v) {
255
add(dfn[x], dfn[x] + siz[x] - 1, v, 1, n, 1);
256
}
257
258
// 从x到y的路径上,查询所有节点的累加和
259
public
static
long pathSum(
int
x,
int
y) {
Callers
1
main
Method · 0.95
Calls
1
add
Method · 0.95
Tested by
no test coverage detected