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

Method rank

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

Source from the content-addressed store, hash-verified

133 }
134
135 public static int rank(int num) {
136 int i = head, last = head;
137 int ans = 0;
138 while (i != 0) {
139 last = i;
140 if (key[i] >= num) {
141 i = left[i];
142 } else {
143 ans += size[left[i]] + 1;
144 i = right[i];
145 }
146 }
147 splay(last, 0);
148 return ans + 1;
149 }
150
151 public static int index(int x) {
152 int i = find(x);

Callers 2

removeMethod · 0.95
mainMethod · 0.95

Calls 1

splayMethod · 0.95

Tested by

no test coverage detected