当前位置:网站首页>LeetCode383. Ransom letter
LeetCode383. Ransom letter
2022-04-22 11:41:00 【Want to get into Ali's chicken】
Ideas
The problem is very simple , Will be ransomNote Store the characters in the array , take magazine Characters in are deleted from the array , If there is greater than or equal to 1 Value , It means magazine There is no ransomNote A character in .
Code
class Solution {
public boolean canConstruct(String ransomNote, String magazine) {
int[] temp = new int[26];
int index = 0;
for(int i =0;i<ransomNote.length();i++){
index = ransomNote.charAt(i) - 'a';
temp[index] += 1;
}
for(int j = 0;j<magazine.length();j++){
index = magazine.charAt(j) - 'a';
temp[index]-=1;
}
for(int i =0;i<26;i++){
if(temp[i] >=1){
return false;
}
}
return true;
}
}
版权声明
本文为[Want to get into Ali's chicken]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221138456937.html
边栏推荐
- L'applet Wechat est installé en utilisant le cadre vantui (vantweapp) Yarn
- PTC: major change in ESG product R & D of construction machinery
- Go开发者调查:92%的开发者对Go感到满意
- Development of digital collection system and construction of digital collection app system
- 九、ES6(2)
- 链表的增删改查等函数封装(汇总)
- FinBI连接本机mysql
- Redis resolves key conflicts
- 解决电脑连接正常,但浏览器无法打开网页的问题
- 11.(地图数据篇)OSM数据如何下载使用
猜你喜欢

Basic operation of MySQL

(10 pieces of terrain data for offline processing)

JS get the width and height of DOM element

观测云入驻阿里云计算巢,为用户构建稳定安全的云上连接

13. (map data) conversion between Baidu coordinate (bd09), National Survey Bureau coordinate (Mars coordinate, gcj02), and WGS84 coordinate system

Summary of important knowledge points of discrete structure and its application

13.(地图数据篇)百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换

C语言猜字游戏和整蛊游戏

200. 岛屿数量

.env.dev不生效问题
随机推荐
(10 pieces of terrain data for offline processing)
Intelligent party building integrated management platform development, digital party building integrated management system
Basic knowledge of machine learning
Chat chat app Lesson 6 creating a main chat static page
PTC: 工程机械ESG产品研发重大变革
【安全建设】日志监控的极品工具sysmon
智慧党建综合管理平台开发,数字党建一体化管理系统
Originally, this is the correct posture for developers to open world book day!
深度学习技术开发与应用
2019-8-8-wpf - touch and mouse click response in non customer area
POSTGRESQL 15 的新功能,值得期待,其中两个被吐槽很久
Start with how to read the AWR report
Redis clears the data of all databases and the currently selected database
MySQL learning notes
L'applet Wechat est installé en utilisant le cadre vantui (vantweapp) Yarn
C language small project ---- > push box
If you are in Russia under "technology sanctions", gbase
2. flddler响应显示乱码问题解决方案
MySQL使用SELECT 语句不加ORDER BY默认是如何排序的?
FinBI连接本机mysql