Tap here to switch tabs
Problem
Submissions

Problem: Sum of Largest Prime Substrings

Sum of Largest Prime Substrings examines every contiguous part of a digit string, keeps distinct values that are prime, and returns the sum of the three largest, or all of them if fewer exist.

Statement

Given a string s consisting of digits, find all unique prime numbers that can be formed by converting any contiguous substring of s into an integer.

Return the sum of the 33 largest unique prime numbers obtained. If fewer than 33 unique prime numbers exist, return the sum of all available unique prime numbers. If no prime numbers can be formed, return 00.

Constraints:

  • 1≤1 \leq s.length ≤10\leq 10

  • s consists of only digits.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Largest Prime Substrings

Sum of Largest Prime Substrings examines every contiguous part of a digit string, keeps distinct values that are prime, and returns the sum of the three largest, or all of them if fewer exist.

Statement

Given a string s consisting of digits, find all unique prime numbers that can be formed by converting any contiguous substring of s into an integer.

Return the sum of the 33 largest unique prime numbers obtained. If fewer than 33 unique prime numbers exist, return the sum of all available unique prime numbers. If no prime numbers can be formed, return 00.

Constraints:

  • 1≤1 \leq s.length ≤10\leq 10

  • s consists of only digits.