Palindrome Check
The problem
You are given a string s. Return true if the string is palindrome, otherwise false.
A string is called palindrome if it reads the same forward and backward.
Input : s = "hannah" Output : true Explanation : The given string when read backward is -> "hannah", which is same as when read forward. Hence answer is true.
Input : s = "aabbaaa" Output : false Explanation : The given string when read backward is -> "aaabbaa", which is not same as when read forward. Hence answer is false.
Input : s = "aabbccbbaa"
- 1 <= s.length <= 105
- s consist of only uppercase and lowercase English characters.
cpp
class Solution{
public:
bool palindromeCheck(string& s){
//your code goes here
}
};java
class Solution {
public boolean palindromeCheck(String s) {
//your code goes here
}
}python
class Solution:
def palindromeCheck(self, s):
#your code goes herejavascript
class Solution {
palindromeCheck(s) {
//your code goes here
}
}csharp
class Solution {
public bool palindromeCheck(string s) {
//your code goes here
}
}go
func palindromeCheck(s string) bool {
//your code goes here
}Stuck? Show a way to structure it+
- 01Set pointers at both ends of the string.
- 02Compare the characters at each pair.
- 03Return false on the first mismatch.
- 04Move inward and return true when pointers cross.
Reference answer
Then expect these follow-ups
How would you ignore punctuation and case?
Tests: input normalization
How would you find the longest palindromic substring?
Tests: string algorithms
Hiring now
Adobe has 203 open roles right now
landed applies to roles like these for you, on each company’s own site, with answers written for the role.
2027 Intern - Solutions Consulting
Paris
2027 Intern - Communications
San Francisco
Adobe Intern FY27
Bangalore
Next question