Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3676944

Browse files
committed
383
1 parent 6be99ae commit 3676944

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

383. Ransom Note.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {string} ransomNote
3+
* @param {string} magazine
4+
* @return {boolean}
5+
*/
6+
var canConstruct = function (ransomNote, magazine) {
7+
let b = false
8+
i = -1
9+
const s = ransomNote.length - 1
10+
while (i < s) {
11+
if (magazine.includes(ransomNote[0])) {
12+
b = true
13+
magazine = magazine.replace(ransomNote[0], "")
14+
ransomNote = ransomNote.replace(ransomNote[0], "")
15+
}
16+
else {
17+
b = false
18+
} i++
19+
}
20+
return b
21+
};

0 commit comments

Comments
 (0)