All Tracks Algorithms Dynamic Programming 2 Dimensional Problem

Next Lucky Number
Tag(s):

Basic Programming, Implementation, Medium, Recursion, Two dimensional

Problem
Editorial
Analytics

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

SAMPLE INPUT
4
4
48
130
98

SAMPLE OUTPUT
5
53
333
333
Time Limit: 2,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Urban Ladder

Challenge Name

Urban Ladder Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Уведомления
View All Notifications

?