# Longest palindromic substring — dynamic programming interview question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/1169/longest-palindromic-subsequence-dynamic-programming
Source observed: 2026-11-05T00:29:21.112Z
Last checked: 2026-11-05T00:29:21.112+00:00
Indexed: 2026-11-07T01:14:26.686+00:00

---

# Find the longest palindromic subsequence using dynamic programming

**Difficulty:** Medium  
**Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms)  
**Reported last asked:** 8 months ago  
**Available roles:** [Software Engineer](https://www.aced.io/questions?role=swe) (3), [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer) (2), [Data Engineer](https://www.aced.io/questions?role=data-engineer) (2)  
**Available company filters:** [Apple](https://www.aced.io/questions?company=apple) (2), [Google](https://www.aced.io/questions?company=google), [Adobe](https://www.aced.io/questions?company=adobe), [Oracle](https://www.aced.io/questions?company=oracle), [Goldman Sachs](https://www.aced.io/questions?company=goldman-sachs), and [LinkedIn](https://www.aced.io/questions?company=linkedin)

Aced, formerly Exponent, provides interview-preparation courses, practice questions, interview experiences, coaching, and related resources for technology and other professional roles. This question is a coding-practice prompt with an editor and output/test-results panels; signing up is required to run code: [Sign up to run code](https://www.aced.io/signup?src=lesson).

## Problem

Given a string `s`, determine the longest **palindromic substring** in `s`. A palindrome reads the same forward and backward. A substring is a contiguous sequence of characters within a string. Return the substring with the greatest length that satisfies this condition.

Although the title mentions a palindromic subsequence, the problem statement specifically defines and asks for a palindromic **substring**, which must be contiguous.

## Example

```text
Input: "abacc"
Output: "aba"
Explanation: "aba" is longer than "cc"
```

## Question workspace

The available tabs and controls are:

- **Question**, **Solution**, and **Community13** tabs.
- An **Editor** and **Share** panel.
- **Output**, **Test Results**, and **Console** panels.
- A **Select** option control.
- A **Copy to clipboard** control for the example section.
- A **Save19** control and a control for reporting that the question was asked.
- Detailed company statistics are available through [Upgrade](https://www.aced.io/upgrade?src=questions).

No community answers have been contributed yet.

## Interview experiences

Two shared experiences are associated with this question:

1. **Apple — 8 months ago** ([experience](https://www.aced.io/experiences/apple-software-engineer-interview-63467f))

   > “Timeline was smooth and interviewers were friendly. Turnaround was quick. and Communication was great”

   **Role:** Software Engineer · Mid Level / L4

2. **Google — 10 months ago** ([experience](https://www.aced.io/experiences/google-machine-learning-engineer-intern-interview-d43fed))

   > “I interviewed for an AI Engineer internship, but the process was mostly DSA-heavy. I had an online coding round first, then a technical round with binary tree and DP questions, then another harder DSA round with DP and linked list questions, and finally an HR round. The online round covered arrays and strings, and the later rounds got progressively more difficult. The only non-DSA part was the last round, where they asked about my projects and previous experience. I didn't share the final outcome, but the main thing that stood out to me was how coding-focused the whole process was.”

   **Role:** Machine Learning Engineer · Intern

## Related questions

- [Find the longest increasing subsequence.](https://www.aced.io/questions/1125/longest-increasing-subsequence)
- [Find the longest alternating subsequence.](https://www.aced.io/questions/1173/longest-alternating-subsequence)
- [Longest Increasing Subsequence](https://www.aced.io/questions/5245/coding-longest-increasing-subsequence)

## Related courses

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for machine-learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies through mock interviews, frameworks, and advice from senior candidates. Topics include ML system design, core concepts, coding, behavioral interviews, and more.

### [Data Engineering Interview Prep](https://www.aced.io/courses/data-engineering)

![Data Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/5XoOCgXlGqN2fa1zaroNWd/9a2e23df48a212bc00d352873feb2d6a/Data_Engineer_Interview_Prep_Hero_Image.jpg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for data-engineering roles at Meta, Google, Amazon, Microsoft, Walmart, DoorDash, and other top companies through mock interviews, frameworks, and advice from senior candidates. Topics include data modeling, pipeline design, SQL, coding, and behavioral interviews.

## Other Aced resources

Our navigation includes interview-preparation courses for Product Management, Forward Deployed Engineering, Engineering Management, Software Engineering, System Design, Data Science, Machine Learning, Data Engineering, AI Engineering, Investment Banking, Generative AI, Security Engineering, TPM, Solutions Architecture, UX/Product Design, and BizOps & Strategy. We also offer question libraries, interview experiences, coding practice, mock interviews and coaching, resume review, salary negotiation, job referrals, resources, and pricing information.

- [All Questions](https://www.aced.io/questions)
- [Courses](https://www.aced.io/courses?src=nav)
- [Practice](https://www.aced.io/practice?src=nav)
- [Experiences](https://www.aced.io/experiences?src=nav)
- [Coaching](https://www.aced.io/coaching?src=nav)
- [Pricing](https://www.aced.io/upgrade?src=nav)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1169%2Flongest-palindromic-subsequence-dynamic-programming&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1169%2Flongest-palindromic-subsequence-dynamic-programming). Opening a form does not execute a tool.