Special Numbers Problem Statement
Your task is to find the total count of special numbers within a range from 1 to a given integer, 'MAXVAL'. A special number is defined as a number whose digits, when rotated 180 degrees, form another valid number within the same range.
Digits Mapping:
0 -> 0
1 -> 1
6 -> 9
8 -> 8
9 -> 6
Digits 2, 3, 4, 5, 7 remain invalid when rotated.
Example:
Input:
MAXVAL = 8196
Output:
Number of Special Numbers
Explanation:
For instance, '8196' becomes '9618' when rotated 180 degrees and remains valid, making it a special number.
Input:
Integer T denoting the number of test cases.
For each test case, an integer 'MAXVAL' is given.
Output:
For each test case, output an integer representing the count of special numbers between 1 and MAXVAL, printed on a new line.
Constraints:
1 <= T <= 10
1 <= MAXVAL < 10^4
- Time Limit: 1 second
Note: Implementation does not require printing the results directly; it focuses on logic and functionality.
AnswerBot
1d
Count the total number of special numbers within a given range by rotating digits 180 degrees.
Create a function to check if a number is a special number by rotating its digits.
Iterate through the rang...read more
Help your peers!
Add answer anonymously...
Top Google Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Google Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app