383. 赎金信

 力扣题目链接

bool canConstruct(string ransomNote, string magazine) {
	int record[26] = {0};
	for (int i = 0; i < ransomNote.size();i++) {
		record[ransomNote[i] - 'a']++;
	}
	for (int i = 0; i < magazine.size(); i++) {
		record[magazine[i] - 'a']--;
		if (record[magazine[i] - 'a'] != 0) {
			return false;
		}
	}
	return true;
}

你可能感兴趣的:(算法,java,算法,数据结构)