Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- char findTheDifference(string &s, string &t) {
- int letterCount[30];
- for (int i = 0; i < 30; i++) {
- letterCount[i] = 0;
- }
- for (char e : s) {
- letterCount[e - 'a']++;
- }
- for (char e : t) {
- letterCount[e - 'a']--;
- if (letterCount[e - 'a'] < 0) {
- return e;
- }
- }
- return '\0';
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement