Skip to content

Latest commit

 

History

History
22 lines (22 loc) · 441 Bytes

383.md

File metadata and controls

22 lines (22 loc) · 441 Bytes

383. Ransom Note

题目链接

int canConstruct(char *ransomNote, char *magazine)
{
    int dict[26] = {0};
    if(ransomNote[0] == '\0')
        return 1;
    int i = 0;
    while(magazine[i] != '\0')
    {
        dict[magazine[i++]-'a']++;
    }
    i = 0;
    while(ransomNote[i] != '\0')
    {
        if(--dict[ransomNote[i++]-'a'] < 0)
            return 0;
    }
    return 1;
}