MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / search

Method search

java/0981-time-based-key-value-store.java:20–31  ·  view source on GitHub ↗
(List<Pair<String, Integer>> list, int timestamp)

Source from the content-addressed store, hash-verified

18 }
19
20 public String search(List<Pair<String, Integer>> list, int timestamp) {
21 int start = 0;
22 int end = list.size() - 1;
23 while (start < end) {
24 int mid = start + (end - start + 1) / 2;
25 if (list.get(mid).getValue() <= timestamp) start = mid; else end =
26 mid - 1;
27 }
28 return list.get(start).getValue() <= timestamp
29 ? list.get(start).getKey()
30 : "";
31 }
32}

Callers 1

getMethod · 0.95

Calls 3

sizeMethod · 0.45
getMethod · 0.45
getKeyMethod · 0.45

Tested by

no test coverage detected