forked from Anuragcoderealy/Codenewhacktober
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRansom.cpp
More file actions
27 lines (27 loc) · 703 Bytes
/
Ransom.cpp
File metadata and controls
27 lines (27 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Solution {
public:
bool canConstruct(string ransomNote, string magazine) {
bool flag;
if(ransomNote.length()>magazine.length())
return false;
else
{
for(int i=0;i<ransomNote.length();i++)
{
flag=false;
for(int j=0;j<magazine.length();j++)
{
if(ransomNote[i]==magazine[j])
{
flag=true;
magazine[j]='*';
break;
}
}
if(flag==false)
break;
}
return flag;
}
}
};