MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / remove

Method remove

src/class153/FollowUp1.java:189–208  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

187 }
188
189 public static void remove(int num) {
190 int kth = rank(num);
191 if (kth != rank(num + 1)) {
192 int i = find(kth);
193 splay(i, 0);
194 if (left[i] == 0) {
195 head = right[i];
196 } else if (right[i] == 0) {
197 head = left[i];
198 } else {
199 int j = find(kth + 1);
200 splay(j, i);
201 left[j] = left[i];
202 father[left[j]] = j;
203 up(j);
204 head = j;
205 }
206 father[head] = 0;
207 }
208 }
209
210 public static void main(String[] args) throws IOException {
211 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Callers 1

mainMethod · 0.95

Calls 4

rankMethod · 0.95
findMethod · 0.95
splayMethod · 0.95
upMethod · 0.95

Tested by

no test coverage detected