Next Lucky Number
Practice
4.7 (16 votes)
Approved
Basic programming
Implementation
Medium
Open
Recursion
Two dimensional
Problem
77% Success 6048 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Lucky numbers are defined as the numbers consisting only of digits 3 and 5. So, given a number N, you have to print the least lucky number strictly greater than N.

Input:
First line of input contains number of test cases T. Each test case contains a single number N.

Output:
For each test case, print the next lucky number in a separate line.

Constraints:
1<=T<=1000
1<=N<=10100

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
13 votes
Tags:
2-D ArrayAlgorithmsApprovedDynamic ProgrammingDynamic programmingMedium
Points:30
5 votes
Tags:
2D dynamic programmingAlgorithmsDynamic Programming
Points:30
8 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingMediumTwo dimensional