Next Lucky Number
Practice
4.7 (16 votes)
Approved
Basic programming
Implementation
Medium
Open
Recursion
Two dimensional
Problem
77% Success 6053 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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
54 votes
Tags:
2D dynamic programmingAlgorithmsDynamic ProgrammingMediumPermutation and combination
Points:30
7 votes
Tags:
Depth First SearchDynamic ProgrammingMediumTwo dimensionalapprovedmatrix
Points:30
58 votes
Tags:
ApprovedDynamic ProgrammingGraphsMathMediumOpenRecursionTwo dimensional
Editorial
Login to unlock the editorial