Java HashMap merge() 方法
hashmap.merge(key, value, remappingFunction)
注:hashmap 是 HashMap 類的一個物件。
引數說明:
key - 鍵
value - 值
remappingFunction - 重新對映函式,用於重新計算值
菜鳥教程連結
If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null.
例如: m.merge(cnt.get(x), -1, Integer::sum)
力扣3092. 最高頻率的 ID
靈神題解