Skip to content

Commit 5b3b29a

Browse files
authored
Merge pull request #32 from Rahul-Bhati/master
#12 issue solve
2 parents 0307738 + 2c7802c commit 5b3b29a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Leetcode/Ransom note/#12.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public boolean canConstruct(String ransomNote, String magazine) {
3+
int arr[] = new int[26];
4+
for (char i : magazine.toCharArray()) {
5+
arr[i - 'a']++;
6+
}
7+
for (char i : ransomNote.toCharArray()) {
8+
if (arr[i - 'a'] == 0) {
9+
return false;
10+
} else {
11+
arr[i - 'a']--;
12+
}
13+
}
14+
return true;
15+
}
16+
}

0 commit comments

Comments
 (0)