Skip to content

Commit 8210dbe

Browse files
Create 383. Ransom Note
1 parent 0723e59 commit 8210dbe

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

383. Ransom Note

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
public:
3+
bool canConstruct(string ransomNote, string magazine) {
4+
if(ransomNote.size()>magazine.size()) return false;
5+
6+
for(int i=0; i<ransomNote.size() ; i++)
7+
{
8+
int p=0;
9+
for(int j=0; j<magazine.size(); j++)
10+
{
11+
if(ransomNote[i]==magazine[j]){
12+
p=1;
13+
magazine[j]=' ';
14+
break;
15+
}
16+
}
17+
if(p==0) return false;
18+
}
19+
20+
21+
return true;
22+
23+
}
24+
};

0 commit comments

Comments
 (0)