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

Method kth

src/class164/Code07_Peaks1.java:68–81  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

66 public static int cntt = 0;
67
68 public static int kth(int num) {
69 int left = 1, right = s, mid;
70 while (left <= right) {
71 mid = (left + right) / 2;
72 if (sorted[mid] == num) {
73 return mid;
74 } else if (sorted[mid] < num) {
75 left = mid + 1;
76 } else {
77 right = mid - 1;
78 }
79 }
80 return -1;
81 }
82
83 public static void prepare() {
84 for (int i = 1; i <= n; i++) {

Callers 1

prepareMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected