当前位置:网站首页>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
- IBM WebSphere MQ retrieving messages
- Li Kou brush question diary /day2/2022.6.24
- NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
- [go ~ 0 to 1] read, write and create files on the sixth day
- Wireshark抓包TLS协议栏显示版本不一致问题
- Go微服务(二)——Protobuf详细入门
- Angry bird design based on unity
- Detailed explanation of issues related to SSL certificate renewal
- DeFi生态NFT流动性挖矿系统开发搭建
猜你喜欢

Scala基础教程--20--Akka

Li Kou brush question diary /day2/2022.6.24

基于lex和yacc的词法分析器+语法分析器

建立自己的网站(15)

LeetCode第300场周赛(20220703)

Use canal and rocketmq to listen to MySQL binlog logs

Scala basic tutorial -- 20 -- akka
![[go ~ 0 to 1] read, write and create files on the sixth day](/img/cb/b6785ad7d7c7df786f718892a0c058.png)
[go ~ 0 to 1] read, write and create files on the sixth day

Scala basic tutorial -- 17 -- Collection

Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
随机推荐
使用FTP
Scala basic tutorial -- 18 -- set (2)
基于lex和yacc的词法分析器+语法分析器
Scala basic tutorial -- 19 -- actor
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
Summary and sorting of 8 pits of redis distributed lock
建立自己的网站(15)
ThreadLocal原理与使用
ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
数组中的第K个最大元素
读写关闭的channel是啥后果?
Scala基础教程--20--Akka
LeetCode FizzBuzz C#解答
A method of using tree LSTM reinforcement learning for connection sequence selection
node_exporter部署
IBM WebSphere MQ检索邮件
技术分享 | 接口测试价值与体系
redis分布式锁的8大坑总结梳理
Scala基础教程--18--集合(二)
千万不要只学 Oracle、MySQL!