Meta 面试题 #5 —— 最多删 1 个字符能否成回文

1次阅读
没有评论

Problem (English original):
Given a string S consisting of lowercase English characters, determine if you can make it a palindrome by removing at most one character.

Example:

  • tacocatstrue. tacocats → remove stacocat.
  • abaabtrue (remove the middle a).
  • baabatrue (remove one of the middle as).

总结(含思路):
双指针从两端向中间比较;首次不等时,尝试跳过左或右各一次,检查任一子串是否回文。时间 O(n),空间 O(1)。

VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 OpenAI、Google、Amazon、Citadel、SIG 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备 Stripe 或类似工程向公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。

正文完
 0