#383.Ransom Note [LeetCode Grind 75 in Java]

[Problem Link] https://leetcode.com/problems/ransom-note/

class Solution {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] charOfMag = new int[26];

        for(char c : magazine.toCharArray()){
            charOfMag[c - 'a'] ++;
        }

        for(char c : ransomNote.toCharArray()){
            if(charOfMag[c - 'a'] > 0) charOfMag[c - 'a'] --;
            else return false;
        }

        return true;
    }
}