FastPrepCount Distinct Palindromic Substrings
Problems/Count Distinct Palindromic Substrings

Count Distinct Palindromic Substrings

Roblox logoRoblox● HardNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report calls a linked distinct-palindrome exercise an exact match, but also uses a label for a modified task. We followed the linked distinct-substring version. We chose lowercase input, what happens with empty input, and the limits. Our version is about 95% the same as the reported question.

Count the different nonempty palindromic substrings of s. A substring uses consecutive characters, and a palindrome reads the same forward and backward.

For this exercise, assume equal substring text is counted once, even when it occurs at different or overlapping positions. Return the number of different palindromes. The empty string contains none and returns 0.

Function

countDistinctPalindromes(s: String) → int

Examples

Example 1

s = "ababa"return = 5

The distinct values are a, b, aba, bab and ababa.

Example 2

s = "aaaa"return = 4

The four distinct values are a, aa, aaa and aaaa, regardless of repeated occurrences.

Example 3

s = ""return = 0

The empty substring is not counted.

Constraints

  • 0 <= s.length <= 5000.
  • Every character is a lowercase English letter.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Inventory Discount TrackerOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025

Similar questions at other companies

  • Minimum Merge ConflictsAmazon · OA
  • Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Balance a Chemical EquationMicrosoft · OAMicrosoft interview questions
  • Longest Repeated Letter Block with Adjacent SwapsIntuit · OAIntuit interview questions
  • Count Substrings Matching with One Adjacent SwapInMobi · OAInMobi interview questions
  • Binary CircuitAkuna Capital · OAAkuna Capital interview questions
  • String Formation (Also for AI/ML Software Engineer Intern :)Snowflake · OASnowflake interview questions
  • Binary Sorting Rounds After FlipsVisa · OAVisa interview questions
  • Minimum Numeric Code TransformationAdobe · OAAdobe interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)

Roblox interview experiences

  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int countDistinctPalindromes(String s) {
        // write your code here
    }

}
Checking account…