Sum of Unique Primes
Medium
array
prime-numbers
frequency-counting
math
Problem Description
Given an array of integers, find the sum of all prime numbers that appear exactly once in the array. A number must be both prime and unique (appears only once) to be included in the sum.
Input Format
First line contains n (array size). Second line contains n space-separated integers.
Output Format
Sum of prime numbers that appear exactly once in the array.
Constraints
• 1 ≤ n ≤ 1000
• 1 ≤ array elements ≤ 1000
• Consider only positive integers
• Prime numbers: 2, 3, 5, 7, 11, 13, ...
• Number must appear exactly once AND be prime
Sample Input/Output
Input:
6 2 3 4 3 5 7
Output:
14
Explanation
Primes in array: 2(once), 3(twice), 5(once), 7(once). Unique primes: 2, 5, 7. Sum: 2+5+7=14.
Solution Hints
95
Points
Points
2500ms
Time Limit
Time Limit
128MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now