Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started