Palindrome String-Asked in interviews

Problem Statement :

You are asked to find whether a given string is a palindrome or not.

Input Format:

The first and only line of the input is a string s.

Output Format:

If the given string is palindrome then print out “Yes” otherwise print out “No”





Explanation of given Test Cases :

The reverse of the given string is equal to the (ABCDCBA) which is equal to the given string. Therefore, the given string is palindrome.


We solve this question by traversing the string and checking whether the character at ith index is equal to the character at the (N-i-1)th index for every index in the range [0, N/2]


Time Complexity: O(N)
Space Complexity: O(1)

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.




Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Smart Enemies Fire from Behind

Ninja And Fibonacci Numbers

Catalogues to TEI to HTML at the National Gallery

Student’s story: Ross — from beginner to a job in Madrid

How to build a simple trading bot skeleton in Python

Automating OCR processes towards translations

Getting started in Augmented Reality (AR) using Unity

MR AR VR Image

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Upskilling students for tech placements!

More from Medium

This Pointer

0/1 Knapsack

Leetcode Series. No 435: Non-overlapping Intervals

Binary Search Tree to Greater Sum Tree