Distinct Palindromic Substrings

Asked at CitadelOnline assessment

Reported by the problem's creator, not verified

Given a string s of lowercase letters, find its distinct palindromic substrings. Implement distinct_palindromes(s), which returns them as a list of strings sorted in lexicographic order.

Examples

  1. Example 1

    Input: s = abaab

    Output: ["a","aa","aba","b","baab"]

    Explanation: Palindromic substrings of abaab are a, b, aa, aba and baab. a occurs three times and b twice, but each distinct value appears once, in sorted order.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.