Back to problems Sign in to unlock
Leetcode
Easy
Arrays
Strings
Hash Maps
Bit Manipulation
Find The Difference
Find the one extra character that appears in a shuffled version of a string.
Acceptance 0%
Problem Statement
Given two strings and , where is formed by shuffling the characters of and adding exactly one extra character at an arbitrary position, identify the extra character.
Return that character as a single-letter string.
Input Format
- Two strings and
- contains all characters of plus one additional character
- Character order in both strings may be arbitrary
Output Format
- Return the extra character that appears in but not in
Constraints
- Strings contain lowercase English letters in the common LeetCode formulation
Examples
Sample cases returned by the problem API.
Example 1
Input
s = "abcd", t = "abcde"
Output
"e"
Explanation
The string t contains every character from s plus one extra character, e.
Example 2
Input
s = "ae", t = "aea"
Output
"a"
Explanation
The extra character in t is a.
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
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.