码迷,mamicode.com
首页 > 其他好文 > 详细

383. Ransom Note

时间:2018-05-26 18:45:15      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:pre   cto   ons   div   ring   vector   als   har   str   

 1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     bool canConstruct(string ransomNote, string magazine) 
12     {
13         vector<int> vi(128,0);
14         for(char c:magazine)
15             vi[c]++;
16         for(char c:ransomNote)
17         {
18             if(--vi[c]<0)
19                 return false;
20         }
21         return true;
22     }
23 };

这里用vector和map都可以

383. Ransom Note

标签:pre   cto   ons   div   ring   vector   als   har   str   

原文地址:https://www.cnblogs.com/zhuangbijingdeboke/p/9093827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!