String t is generated by shuffling string s and then inserting one extra character at a random position. Return the extra character as a one-character String. Treat a null s as an empty string. Assume t is non-null and contains exactly one more character than s.
Examples:
Input: s = 'abcd', t = 'abcde'
Output: 'e'
Explanation: e is the extra character added to t
Input: s = '', t = 'y'
Output: 'y'
Explanation: y is the only character, so it is the extra one
Input: s = 'a', t = 'aa'
Output: 'a'
Explanation: One extra a was inserted, so the difference is a
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay October 2026 (Oct 4–15)Sponsored by FLXBL
Contest runs October 4 - 15. Complete challenges to climb the leaderboard!
Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes
Only the 12 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.