当前位置:网站首页>Leetcode ransom letter C # answer
Leetcode ransom letter C # answer
2022-07-04 19:20:00 【charlsdm】
- Ransom letter
Here are two strings :ransomNote and magazine , Judge ransomNote Can it be done by magazine The characters inside make up .
If possible , return true ; Otherwise return to false .
magazine Each character in can only be in ransomNote Used once in .
Example 1:
Input :ransomNote = “a”, magazine = “b”
Output :false
Example 2:
Input :ransomNote = “aa”, magazine = “ab”
Output :false
Example 3:
Input :ransomNote = “aa”, magazine = “aab”
Output :true
Tips :
1 <= ransomNote.length, magazine.length <= 105
ransomNote and magazine It's made up of lowercase letters
Pass times 193,359 Submit the number 306,645
Below is my AC Code
public partial class Solution
{
public static bool CanConstruct(string ransomNote, string magazine)
{
char[] ramchars = ransomNote.ToCharArray();
char[] magachars = magazine.ToCharArray();
List<char> listram = ramchars.ToList<char>();
List<char> listmaga = magachars.ToList<char>();
int CountA = listmaga.Count;
int CountB = listram.Count;
for (int i = 0; i < CountA; i++)
{
char c = listmaga[i];
if (listram.Contains(c))
{
listram.Remove(c);
}
}
if (listram.Count > 0)
{
return false;
}
return true;
}
}
边栏推荐
- 使用FTP
- How to modify icons in VBS or VBE
- 删除字符串中出现次数最少的字符【JS,Map排序,正则】
- 2022CoCa: Contrastive Captioners are Image-Text Fountion Models
- 2022健康展,北京健博会,中国健康展,大健康展11月13日
- Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
- Scala基础教程--18--集合(二)
- Li Chi's work and life summary in June 2022
- 整理混乱的头文件,我用include what you use
- MXNet对GoogLeNet的实现(并行连结网络)
猜你喜欢
千万不要只学 Oracle、MySQL!
Scala basic tutorial -- 20 -- akka
神经网络物联网应用技术学什么
Scala基础教程--18--集合(二)
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
Nebula Importer 数据导入实践
DeFi生态NFT流动性挖矿系统开发搭建
Wireshark packet capturing TLS protocol bar displays version inconsistency
Process of manually encrypt the mass-producing firmware and programming ESP devices
redis分布式锁的8大坑总结梳理
随机推荐
6.26cf simulation race e: solution to the problem of price maximization
LeetCode FizzBuzz C#解答
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
2022年字节跳动日常实习面经(抖音)
Scala基础教程--19--Actor
6.26CF模拟赛E:价格最大化题解
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
[mathematical modeling of graduate students in Jiangxi Province in 2022] analysis and code implementation of haze removal by nucleation of water vapor supersaturation
删除字符串中出现次数最少的字符【JS,Map排序,正则】
Scala基础教程--15--递归
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import 'fmt' func
Scala基础教程--18--集合(二)
自由小兵儿
其他InterSystems %Net工具
更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
Scala基础教程--13--函数进阶
Scala基础教程--20--Akka
模板_大整数减法_无论大小关系