Member-only story
HackerRank Coding Interview 10.Palindrome Substrings — Part 1 — Question
Frequently asked question and mostly liked by interviewers a lot.
Recommended Time: 27 minsPoints: 10015 test cases (3 samples)
Asked in = Netflix, Amazon, Uber, Lyft, Bloomberg, Morgan Stanley, Apple, and Google, Synchrony.
Skills:Problem Solving (Advanced)
Coding- HARD, Dynamic Programming, Strings, Enumeration
Languages: Python
Insights — It should be read very carefully read and you must ask questions in between.
Problem Statement
For a string s and an integer k, a selection of substrings is valid if the following conditions are met:
- The length of every substring is greater than or equal to k
- Each substring is a palindrome.
- No two substrings overlap.
Determine the maximum number of valid substrings that can be formed from s.
Notes:
- A substring is a group of adjacent characters in a string.
- A palindrome is a string that reads the same backward as forward.
Example
s = “aababaabce”
k = 3
a ababa abce
a aba baab ce