389. Find the Difference Easy
1/**
2 * [389] Find the Difference
3 *
4 * You are given two strings s and t.
5 * String t is generated by random shuffling string s and then add one more letter at a random position.
6 * Return the letter that was added to t.
7 *
8 * Example 1:
9 *
10 * Input: s = "abcd", t = "abcde"
11 * Output: "e"
12 * Explanation: 'e' is the letter that was added.
13 *
14 * Example 2:
15 *
16 * Input: s = "", t = "y"
17 * Output: "y"
18 *
19 *
20 * Constraints:
21 *
22 * 0 <= s.length <= 1000
23 * t.length == s.length + 1
24 * s and t consist of lowercase English letters.
25 *
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/find-the-difference/
30// discuss: https://leetcode.com/problems/find-the-difference/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35 pub fn find_the_difference(s: String, t: String) -> char {
36 '0'
37 }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn test_389() {
48 }
49}
50
Back
© 2025 bowen.ge All Rights Reserved.