Skip to content

Instantly share code, notes, and snippets.

@inspector-ambitious
Created April 5, 2022 06:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inspector-ambitious/d97f645b79162eab503718ab999063e3 to your computer and use it in GitHub Desktop.
Save inspector-ambitious/d97f645b79162eab503718ab999063e3 to your computer and use it in GitHub Desktop.

Find the difference

You are given two strings s and t.

String t is generated by random shuffling string s and then add one more letter at a random position.

Return the letter that was added to t.

Example 1:

Input: s = "abcd", t = "abcde"
Output: "e"
Explanation: 'e' is the letter that was added.

Example 2:

Input: s = "", t = "y"
Output: "y"

Function templates

Javascript

/**
 * @param {string} s
 * @param {string} t
 * @return {character}
 */
var findTheDifference = function(s, t) {
    
};

Ruby

# @param {String} s
# @param {String} t
# @return {Character}
def find_the_difference(s, t)
    
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment