Skip to main content
Back to problems
Codeforces
Easy
Strings
Math
Appleman and Easy Task

Given a string, determine whether every character appears an even number of times.

Acceptance 0%
Problem Statement

Problem

You are given a string consisting of lowercase Latin letters. Decide whether each distinct character occurs an even number of times in the string.

Return YES if all character frequencies are even, otherwise return NO.

Notes

  • A character may appear zero times, one time, or many times.
  • You only need to check the parity of each frequency, not the exact counts.

Input Format

  • A single string s.

Output Format

  • Print YES if every character in s appears an even number of times.
  • Otherwise print NO.

Constraints

  • 1 <= |s| <= $10^{5}$
  • s contains only lowercase English letters.

Hints

  • Count how many times each letter appears.
  • Alternatively, track whether each count is even or odd as you scan the string.

Input Format

A single lowercase string s.

Output Format

Print YES if all character frequencies are even, otherwise print NO.

Constraints

  • 1 <= |s| <= $10^{5}$
  • s contains only lowercase English letters.
Examples
Sample cases returned by the problem API.

Example 1

Input

aabb

Output

YES

Explanation

a appears 2 times and b appears 2 times, so every frequency is even.

Example 2

Input

abac

Output

NO

Explanation

a appears 2 times, but b and c appear once each, so not all frequencies are even.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.