All problems
0663EasyArrayHash TableCounting

Face Values Held Only Once

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1748Sum of Unique Elements

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A stamp album lists the face value of every stamp mounted in it, in mounting order, as the list faces. A face value is called a singleton when exactly one stamp in the album carries it.

Return the total of the singleton face values. A face value carried by two or more stamps contributes nothing at all, not even one copy. Return 0 when the album holds no singleton.

Examples

Example 1

Input
faces = [8, 3, 8, 5]
Output
8

Face value 8 is carried by two stamps, so it drops out. The singletons are 3 and 5, which total 8.

Example 2

Input
faces = [7, 7, 7, 2]
Output
2

Three stamps carry face value 7, so it is not a singleton. Only 2 is, and the total is 2.

Example 3

Input
faces = [6, 6, 6]
Output
0

Every stamp in the album carries the same face value, so the album holds no singleton and the total is 0.

Constraints

  • 1 <= faces.length <= 100
  • 1 <= faces[i] <= 100

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def sum_singleton_values(faces: list[int]) -> int:
Java
public int sumSingletonValues(int[] faces)
September 7
Apply