Given a string s, return true if it is a palindrome, or false otherwise.
Input:s = "aba"
Output:true
This problem checks whether a string is a palindrome, meaning it reads the same forward and backward.
Typical approach:
- Use two pointers, comparing characters from the beginning and end.
- If all pairs match, return
true; otherwise returnfalse.
Runs in O(n) time and O(1) space (two-pointer approach).
The VOprep team has long accompanied candidates through various major company OAs and VOs, including Tiktok, Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for Tiktok or similar engineering-focused companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.