As reported: Epic Systems online assessment, 2025 — one of four programming questions: Palindromic Substrings, but print every palindromic substring of length 3 or more.
This is a variant of LeetCode 647 — Palindromic Substrings, which counts them. Our write-up of the original: /palindromic-substrings.
Given a string s, return every palindromic substring of s whose length is at least 3. A substring is a contiguous block of characters; a palindrome reads the same forwards and backwards.
Order the result by start index, and for the same start by length (shorter first). Substrings at different positions are listed separately even if they are equal.
Example 1
s = "abaab"
Output: ["aba", "baab"]
aba starts at 0, baab at 1. aa is too short.
Example 2
s = "racecar"
Output: ["racecar", "aceca", "cec"]
They start at 0, 1 and 2.
Example 3
s = "abc"
Output: []
Constraints: 1 <= s.length <= 200; s contains lowercase English letters and digits.
Code runner format: one JSON string, s. Implement palindromes(s) returning a list of strings.