[LeetCode] Ransom Note
In fact, arrays can be used to replace hash maps since the test cases of this problem only contan the 26 English letters. A array-version solution can be found here and is rewritten below.
This code takes about 150ms.
This version is much faster, about 13ms.
A very typical application of hash maps. Since I am now learning Java, I code in Java. The following code uses toCharArray() and getOrDefault(), which are learnt from this post.