Skip to content

Instantly share code, notes, and snippets.

@RakhmedovRS
Created October 20, 2022 02:12
Show Gist options
  • Select an option

  • Save RakhmedovRS/31ece65053aa029c2cffe9db03a894be to your computer and use it in GitHub Desktop.

Select an option

Save RakhmedovRS/31ece65053aa029c2cffe9db03a894be to your computer and use it in GitHub Desktop.
Map<Integer, Integer> valueToCount = new HashMap<>();
int max = 0;
for (int num : nums) {
int count = valueToCount.getOrDefault(num, 0) + 1;
valueToCount.put(num, count);
max = Math.max(max, count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment