Split a String into Three Palindromes
Updated
Problem statement
Given a string s, return true if it can be split into exactly three non-empty contiguous substrings such that every substring is a palindrome. Otherwise, return false.
A palindrome reads the same from left to right and right to left. The three substrings must preserve the original order and together use every character of s exactly once.
Function
canSplitIntoThreePalindromes(s: String) → booleanExamples
Example 1
s = "abcbdd"return = trueOne valid split is "a" | "bcb" | "dd". All three pieces are non-empty palindromes.
Example 2
s = "bcbddxy"return = falseNo placement of two split points makes all three resulting substrings palindromes.
Example 3
s = "aaa"return = trueThe only valid three-part split is "a" | "a" | "a", and each one-character substring is a palindrome.
Constraints
3 <= s.length <= 2000.scontains only lowercase English letters.
More Oracle Onsite Interview questions
- Course ScheduleONSITE INTERVIEW · Seen Nov 2026
- Shortest Subarray with Sum at Least KONSITE INTERVIEW · Seen Nov 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
- Minimum Meeting RoomsONSITE INTERVIEW · Seen Nov 2026
- Shortest Window with Required CountsONSITE INTERVIEW · Seen Nov 2026
- Maximum Subarray Sum with One DeletionONSITE INTERVIEW · Seen Nov 2026
- Shortest Deletion for Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
- Count Dropped Rate-Limited RequestsONSITE INTERVIEW · Seen Nov 2026
- Design Authentication ManagerONSITE INTERVIEW · Seen Oct 2026
- Maximum Bouquet ValueONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Word BreakGoogle · ONSITE INTERVIEWGoogle interview questions
- Reconstruct One Sentence From a DictionaryMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Scramble StringExpedia · ONSITE INTERVIEWExpedia interview questions
- Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
- Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Decode Numeric StringArcesium · ONSITE INTERVIEWArcesium interview questions
- Word BreakBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Count Vowel PermutationsZscaler · ONSITE INTERVIEWZscaler interview questions
- Minimum Steps on a Circular Character DialNavan · ONSITE INTERVIEWNavan interview questions