当前位置:网站首页>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;
}
}
边栏推荐
- MXNet对GoogLeNet的实现(并行连结网络)
- 中国农科院基因组所汪鸿儒课题组诚邀加入
- Deleting nodes in binary search tree
- 2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
- Nebula importer data import practice
- Scala basic tutorial -- 17 -- Collection
- Microservice architecture debate between radical technologists vs Project conservatives
- LeetCode FizzBuzz C#解答
- Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
- How to modify icons in VBS or VBE
猜你喜欢
Go microservice (II) - detailed introduction to protobuf
How is the entered query SQL statement executed?
Li Kou brush question diary /day1/2022.6.23
2022 ByteDance daily practice experience (Tiktok)
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
Don't just learn Oracle and MySQL!
Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
Use canal and rocketmq to listen to MySQL binlog logs
A method of using tree LSTM reinforcement learning for connection sequence selection
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
随机推荐
Build your own website (15)
Caché WebSocket
876. 链表的中间结点
一种将Tree-LSTM的强化学习用于连接顺序选择的方法
[mathematical modeling of graduate students in Jiangxi Province in 2022] analysis and code implementation of haze removal by nucleation of water vapor supersaturation
Scala基础教程--13--函数进阶
2019年蜀山区第十五届青少年信息学竞赛
2021 合肥市信息学竞赛小学组
Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
神经网络物联网应用技术就业前景【欢迎补充】
Microservice architecture debate between radical technologists vs Project conservatives
模板_判断素数_开方 / 六素数法
Use canal and rocketmq to listen to MySQL binlog logs
【机器学习的数学基础】(一)线性代数(Linear Algebra)(上+)
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
6.26CF模拟赛E:价格最大化题解
Wireshark网络抓包
使用canal配合rocketmq监听mysql的binlog日志
技术分享 | 接口测试价值与体系
ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr