Find the Difference

EasyBit Manipulationbit manipulation

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

String t was made by taking string s, shuffling its characters into some order, and then inserting **one extra** lowercase letter at some position. Return that extra letter as a single-character string. The extra letter may be a letter that already appears in s.

Examples

Input: s = "abcd", t = "abcde"
Output: "e"
`e` is the only letter in `t` that is not accounted for by `s`.
Input: s = "", t = "y"
Output: "y"
`s` is empty, so the single letter of `t` is the added one.
Input: s = "a", t = "aa"
Output: "a"
The added letter duplicates an existing one.

Constraints

  • 0 <= s.length <= 1000
  • t.length == s.length + 1
  • `s` and `t` consist of lowercase English letters
  • `t` is a shuffle of `s` plus exactly one extra letter

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More bit manipulation problems