/**
* @param {string} ransomNote
* @param {string} magazine
* @return {boolean}
*/
var canConstruct = function(ransomNote, magazine) {
let lenR = ransomNote.length;
let list = magazine.split('');
for(let i = 0; i < lenR; ++i) {
let index = list.indexOf(ransomNote[i]);
if(index === -1) {
return false;
}
list.splice(index, 1);
}
return true;
};
複製代碼