**QUESTION**

Text

Image

Code in JAVA PLZ! please add comments as well. -- as optimal as possible.

1. Code Question 1 A recently launched supplemental typing keypad gained significant popularity on Amazon Shopping due to its flexibility. This keypad can be connected to any electronic device and has 9 buttons, where each button can have up to 3 lowercase English letters. The buyer has the freedom to choose which letters to place on a button while ensuring that the arrangement is valid. A keypad design is said to be valid if: - All 26 letters of the English alphabet exist on the keypad. - Each letter is mapped to exactly one button. - A button has at most 3 letters mapped to it. Examples of some valid keypad designs are:

Examples of some valid keypad designs are: \begin{tabular}{|c|c|c|} \hline 1 & 2 & 3 \\ $\mathrm{abc}$ & def & ghi \\ \hline 4 & 5 & 6 \\ $\mathrm{jkl}$ & $\mathrm{mno}$ & $\mathrm{pqr}$ \\ \hline 7 & 8 & 9 \\ stu & $\mathrm{vwx}$ & $\mathrm{yz}$ \\ \hline \end{tabular} - In the left keypad, "hello" can be typed using the following button presses: [3] twice (prints ' $h$ '), [2] twice (prints 'e'), [4] thrice (prints ' ''), [4] thrice (prints ' ')', [5] thrice (prints 'o'). Thus, total number of button presses = $2+2+3+3+3=13$ - In the right keypad, "hello" can be typed using the following button presses: [5] once (prints ' $h$ '), [7] once (prints 'e'), [6] twice (prints 'I'), [6] twice (prints 'I'), [2] twice (prints 'o'). Thus, total number of button presses = $1+1+2+2+2=8$

The keypad click count is defined as the number of button presses required to print a given string. In order to send messages faster, customers tend to set the keypad design in such a way that the keypad click count is minimized while maintaining its validity. Given a string text consisting of lowercase English letters only, find the minimum keypad click count. Example text = "abacadefghibj". One of the optimal keypad designs to minimize the keypad click count is: \begin{tabular}{|c|c|c|} \hline $\begin{array}{c}1 \\ \text { ajs }\end{array}$ & $\begin{array}{c}2 \\ \text { bkt }\end{array}$ & $\begin{array}{c}3 \\ \text { clu }\end{array}$ \\ \hline $\begin{array}{c}4 \\ \text { dmv }\end{array}$ & $\begin{array}{c}5 \\ \text { enw }\end{array}$ & $\begin{array}{c}6 \\ \text { fox }\end{array}$ \\ \hline $\begin{array}{c}7 \\ \text { gpy }\end{array}$ & $\begin{array}{c}8 \\ \text { hqz }\end{array}$ & $\begin{array}{c}9 \\ \text { ir }\end{array}$ \\ \hline \end{tabular}