Skip to content

Commit 35ac39d

Browse files
committed
✨ feat: 383 Ransom Note
1 parent 660c5ca commit 35ac39d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.fghpdf.RansomNote;
2+
3+
public class Solution {
4+
public boolean canConstruct(String ransomNote, String magazine) {
5+
if (ransomNote.length() > magazine.length()) return false;
6+
int[] alphabets_counter = new int[26];
7+
8+
for (char c : magazine.toCharArray())
9+
alphabets_counter[c-'a']++;
10+
11+
for (char c : ransomNote.toCharArray()){
12+
if (alphabets_counter[c-'a'] == 0) return false;
13+
alphabets_counter[c-'a']--;
14+
}
15+
return true;
16+
}
17+
}

src/com/fghpdf/ValidTicTacToeState.java renamed to src/com/fghpdf/ValidTicTacToeState/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fghpdf;
1+
package com.fghpdf.ValidTicTacToeState;
22

33
class Solution {
44

0 commit comments

Comments
 (0)