K Palindrome Integers
Coding Problem Keys
K Palindrome Integers
Problem Statement
The program accepts two integers N and K as the input. The program must print the first K palindrome integers greater than N as the output.Input Format
The first line contains the value of N and K separated by a space.Output Format
The first line contains K integers representing the first K palindrome integers greater than N.Boundary Condition(s)
1 <= N <= 10⁷1 <= K <= 1000
Example Input/Output 1
Input
1221 5Output
1331 1441 1551 1661 1771
Explanation
Here N = 1221 and K = 5.
The first 5 palindrome integers greater than 1221 are 1331, 1441, 1551, 1661 and 1771.
Hence the output is
1331 1441 1551 1661 1771
Example Input/Output 2
Input
658100 10Output
658856 659956 660066 661166 662266 663366 664466 665566 666666 667766Max Execution Time Limit: 500 millisecs
Solution
Programming Language: Python 3 Language
n,k=map(int,input().split())
count=0
while(count<k):
n+=1
if(str(n)[::-1]==str(n)):
print(n,end=" ")
count+=1
# Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments