Question: Use Java, Do not import any packages (only java.lang.*), write public static boolean func(int num) It checks if all digits in num are in the
Use Java, Do not import any packages (only java.lang.*), write public static boolean func(int num)
It checks if all digits in num are in the same row or column of the numpad. If num only has 1 digit (0 - 9), it will count as in the same row or column. You can assume that num is not negative. The rows of the numpad are {0, 123, 456, 789}, and the columns are {0147, 0258, 0369}. Notice that 0 is a wildcard that counts for all three columns.
| 7 | 8 | 9 |
| 4 | 5 | 6 |
| 1 | 2 | 3 |
| 0 | ||
Examples:
input: 45767
output: false
input: 11231
output: true
input:7711404
output: true
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
