FastPrepFirst Non-Repeated Character

First Non-Repeated Character

Dell Technologies logoDell Technologies● EasyFULLTIMEPHONE SCREEN
Learn

Problem statement

Given a string s, return the first character whose total frequency in the complete string is exactly one.

Character comparison is case-sensitive. Return the empty string when no character occurs exactly once.

Function

firstNonRepeatedCharacter(s: String) → String

Examples

Example 1

s = "swiss"return = "w"

The first s repeats, while w appears once and is encountered before i.

Example 2

s = "aabbcc"return = ""

Every character repeats, so there is no qualifying result.

Constraints

  • 0 <= s.length <= 10^5.
  • Every character is printable ASCII.

More Dell Technologies problems

See Dell Technologies hiring insights
public String firstNonRepeatedCharacter(String s) {
    // Write your solution here.
}
s"swiss"
expected"w"
Checking account…