Skip to main content
Skip to content

Strings · Intermediate

Palindrome Program in Hindi Programming

Two-pointer palindrome check that ignores capital letters.

The program

Edit anything and press Run. The output below was produced by running this exact code.

Expected output

Press Run to try it

Naman -> palindrome haiMalayalam -> palindrome haiAltFLang -> palindrome nahi haiKayak -> palindrome haiChai -> palindrome nahi hai

How it works

A palindrome reads the same forwards and backwards. chhota lowercases the word first so that "Naman" counts. Then two positions walk towards each other: left from the start and right from the end.

You can read a single character of text with square brackets, exactly like a list item. If the two characters ever differ, the word is not a palindrome and the function returns galat straight away. If the pointers meet without a mismatch, it returns sahi.

The one-line alternative is chhota(word) == ulta(chhota(word)) — but the loop shows what that shortcut is doing for you.