MCPcopy
hub / github.com/qiyuangong/leetcode / put

Method put

java/706_Design_HashMap.java:4–12  ·  view source on GitHub ↗
(int key, int value)

Source from the content-addressed store, hash-verified

2 final ListNode[] nodes = new ListNode[10000];
3 // https://leetcode.com/problems/design-hashmap/discuss/152746/Java-Solution
4 public void put(int key, int value) {
5 int i = idx(key);
6 if (nodes[i] == null)
7 nodes[i] = new ListNode(-1, -1);
8 ListNode prev = find(nodes[i], key);
9 if (prev.next == null)
10 prev.next = new ListNode(key, value);
11 else prev.next.val = value;
12 }
13
14 public int get(int key) {
15 int i = idx(key);

Callers 15

subarraySumMethod · 0.45
isAlienSortedMethod · 0.45
topKFrequentMethod · 0.45
twoSumMethod · 0.45
repeatedNTimesMethod · 0.45
addMethod · 0.45
mostCommonWordMethod · 0.45
findShortestSubArrayMethod · 0.45
pushMethod · 0.45
intToRomanMethod · 0.45
subdomainVisitsMethod · 0.45
maxNumberOfBalloonsMethod · 0.45

Calls 2

idxMethod · 0.95
findMethod · 0.95

Tested by

no test coverage detected