Given a string s representing an integer, count the number of ways to split the string into one or more prime numbers.
The digits must stay in their original order, and every digit in s must be used exactly once.
Each split segment must be interpreted as a decimal integer and must be prime.
Examples
01 · Example 1
s = "11375" return = 3
The string can be split into primes in three ways: [11, 37, 5], [11, 3, 7, 5], and [113, 7, 5].
Constraints
scontains only digits.- The answer fits in a 32-bit signed integer.
More Salesforce problems
- Key Teams in TreeOA · Seen Mar 2026
- System Energy ReductionOA · Seen Mar 2026
- Update Logs by Symmetric XOROA · Seen Mar 2026
- Count Palindromic Concatenation PairsOA · Seen Mar 2026
- Collect Opportunity Data in a TreeOA · Seen Feb 2026
- Replace '?' to Avoid Adjacent DuplicatesOA · Seen Feb 2026
- Strings With No k Consecutive Identical CharactersOA · Seen Feb 2026
- Longest Subsequence which is a SubstringOA · Seen Dec 2025
public int countPrimeStrings(String s) {
// write your code here
}s"11375"
expected3
sign in to submit