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

Method sort

src/class174/Code05_Lcm1.java:52–65  ·  view source on GitHub ↗
(int[] idx, int[] val, int l, int r)

Source from the content-addressed store, hash-verified

50 public static boolean[] ans = new boolean[MAXQ];
51
52 public static void sort(int[] idx, int[] val, int l, int r) {
53 if (l >= r) return;
54 int i = l, j = r, pivot = val[idx[(l + r) >> 1]], tmp;
55 while (i <= j) {
56 while (val[idx[i]] < pivot) i++;
57 while (val[idx[j]] > pivot) j--;
58 if (i <= j) {
59 tmp = idx[i]; idx[i] = idx[j]; idx[j] = tmp;
60 i++; j--;
61 }
62 }
63 sort(idx, val, l, j);
64 sort(idx, val, i, r);
65 }
66
67 public static void build() {
68 for (int i = 1; i <= n; i++) {

Callers 15

computeMethod · 0.95
prepareMethod · 0.95
prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45
maxValueMethod · 0.45
nearMethod · 0.45

Calls

no outgoing calls

Tested by 2

checkMethod · 0.36
prepareMethod · 0.36