First N Alphabets Palindrome

 Coding Problem Keys 

 First N Alphabets Palindrome 

 Problem Statement 

The program must accept a string S and an integer value N as the input. Then the program must print Yes if the first N alphabets in S form a palindrome. Else the program must print No. The comparison is NOT case sensitive.

 Boundary Condition(s) 

2 <= Length of S <= 1000
2 <= N <= Length of S

 Input Format 

The first line contains S.
The second line contains N.

 Output Format 

The first line contains Yes or No.

 Example Input/Output 1 

 Input 

leveLling
5

 Output 

Yes

 Explanation 

The first 5 alphabets are LeveL which is a palindrome (as the comparison is not case sensitive).
So the output is Yes.

 Example Input/Output 2 

 Input 

malayalam
6

 Output 

No

 Explanation 

The first 6 alphabets are malaya which is NOT a palindrome.
So the output is No.

 Note: Max Execution Time Limit: 500 millisecs 

 Solution 

 Programming Language: Python 3 Language 

l=input().strip().lower()
n=int(input())
if l[:n]==l[:n][::-1]:
    print("Yes")
else:
    print("No")

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Highly Profitable Months

Minimum Sum of Non-Negative Elements

Largest Possible Number With Digits

Top Scoring Batsman - TEST ODI 20-20

Print OddEven

Count Embedded Integers in String

String - Vowels Position Sum