Skip to content

Commit b06f321

Browse files
BarklimBarklim
Barklim
authored and
Barklim
committed
Create 0389.js
1 parent 139e7f4 commit b06f321

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

0389-find-the-difference.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ var findTheDifference = function(s, t) {
2222
s.split('').forEach(c => map.set(c, map.get(c) - 1));
2323
return Array.from(map).find(([letter, count]) => count)[0];
2424
};
25+
26+
// var findTheDifference = function(s, t) {
27+
// const map = new Map()
28+
// t.split('').forEach(char => map.set(char, (map.get(char) || 0 ) + 1))
29+
// s.split('').forEach(char => map.set(char, map.get(char) - 1))
30+
// return Array.from(map).find(([char, count]) => count)[0]
31+
// };
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {character}
5+
*/
6+
var findTheDifference = function(s, t) {
7+
8+
};
9+
10+
const example1 = findTheDifference("abcd", "abcde"); // "e"
11+
const example2 = findTheDifference("","y"); // "y"
12+
const example3 = findTheDifference("bro", "rosb"); // "s"
13+
14+
console.log(example1);
15+
console.log(example2);
16+
console.log(example3);

example/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,5 @@ Better order to solve problems
201201

202202
### [0.Basic](https://github.com/Barklim/leetcode-javascript/tree/master/example/ProgrammingSkills/0.Basic)
203203

204-
1768. Merge Strings Alternately
204+
1768. Merge Strings Alternately
205+
389. Find the Difference

0 commit comments

Comments
 (0)