Is the String a Palindrome
Updated
Problem statement
Given a string s, return true if it reads the same from left to right and from right to left, and false otherwise.
Compare characters exactly: an upper-case letter and its lower-case form are different characters, and spaces, digits and punctuation count like any other character.
Function
isPalindrome(s: String) → booleanExamples
Example 1
s = "step on no pets"return = trueReversing the string one character at a time, spaces included, gives step on no pets again, so the answer is true.
Example 2
s = "Noon"return = falseThe first character N is upper case and the last character n is lower case. They are different characters, so the answer is false.
Example 3
s = "ab#ba"return = trueThe pairs from the outside in are a/a and b/b, and the middle # has no partner. Every pair matches, so the answer is true.
Constraints
1 <= s.length <= 10^5shas only printable ASCII characters (codes 32 to 126)
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Valid ParenthesesByteDance · PHONE SCREENByteDance interview questions
- Check if a String Is a PalindromeCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Reverse a StringAmazon · PHONE SCREEN
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
- Reverse a String ManuallyNewgen Software · PHONE SCREEN
- Reverse a String with Two PointersSnowflake · PHONE SCREENSnowflake interview questions
- Palindrome with One DeletionWhatNot · PHONE SCREENWhatNot interview questions
- Valid Word AbbreviationMeta · PHONE SCREENMeta interview questions
- Validate a Bracket SequenceTripAdvisor · PHONE SCREEN