FastPrepLetter Set Difference

Letter Set Difference

Bloomberg LP logoBloomberg LP● EasyFULLTIMEPHONE SCREEN
Learn

Problem statement

Return a string containing each distinct character that appears in exactly one of first and second, sorted by ascending character code.

Function

letterSetDifference(first: String, second: String) → String

Examples

Example 1

first = "apple"second = "pear"return = "lr"

l occurs only in apple and r only in pear; a, p, and e occur in both.

Constraints

  • Each string contains at most 10^5 ASCII characters.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public String letterSetDifference(String first, String second) {
  // Write your code here.
}
first"apple"
second"pear"
expected"lr"
Checking account…