We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c88c389 commit ec5c902Copy full SHA for ec5c902
389-find-the-difference.js
@@ -0,0 +1,19 @@
1
+/**
2
+ * @param {string} s
3
+ * @param {string} t
4
+ * @return {character}
5
+ */
6
+var findTheDifference = function(s, t) {
7
+ let newMapS = new Map();
8
+
9
+ for(let i = 0; i < s.length; i++) {
10
+ newMapS.set(s[i], (newMapS.get(s[i]) || 0) + 1);
11
+ }
12
13
+ for (let j = 0; j < t.length; j++) {
14
+ if (!newMapS.has(t[j]) || newMapS.get(t[j]) === 0) {
15
+ return t[j];
16
17
+ newMapS.set(t[j], newMapS.get(t[j]) - 1);
18
19
+};
0 commit comments