MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / LockingTree

Method LockingTree

java/1993-operations-on-tree.java:6–16  ·  view source on GitHub ↗
(int[] parent)

Source from the content-addressed store, hash-verified

4 private final Map<Integer, List<Integer>> child;
5
6 public LockingTree(int[] parent) {
7 this.parent = parent;
8 locked = new int[parent.length];
9 child = new HashMap<>();
10
11 for (int i = 0; i < parent.length; i++) {
12 child.putIfAbsent(parent[i], new ArrayList<>());
13 child.putIfAbsent(i, new ArrayList<>());
14 child.get(parent[i]).add(i);
15 }
16 }
17
18 public boolean lock(int num, int user) {
19 if (locked[num] <= 0) {

Callers

nothing calls this directly

Calls 2

addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected