First
GFGunknown
java
3 years ago
428 B
7
Indexable
class Solution {
public int antiqueItems(int n, int items[], int price[]){
Map<Integer, Integer> hm = new HashMap<>();
for(int i = 0; i < n; i++){
int cur = hm.getOrDefault(items[i], Integer.MAX_VALUE);
if(price[i] < cur)
hm.put(items[i], price[i]);
}
int ans = 0;
for(int x : hm.values())
ans += x;
return ans;
}
}
Editor is loading...