MCPcopy Create free account
hub / github.com/Rohit91singh9/Coding-DP-DSA / minimumKeypad

Class minimumKeypad

minimumKeypad.java:5–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import java.util.Arrays;
4
5public class minimumKeypad {
6 public static void main(String[] args) {
7 String str = "abcghdiefjoba";
8 int[] countocc = new int[26];
9 for (char c : str.toCharArray()) {
10 countocc[c - 'a']++;
11 }
12 Arrays.sort(countocc);
13 int res = 0, clicks = 1, numsused = 0;
14 for (int i = 25; i >= 0; i--) {
15 if (countocc[i] == 0)
16 continue;
17 res += countocc[i] * clicks;
18 numsused++;
19 if (numsused == 9) {
20 numsused = 0;
21 clicks++;
22 }
23 }
24 System.out.println(res);
25 }
26}
27
28
29// Approach 2

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected