当前位置:网站首页>面试题 01.01. 判定字符是否唯一
面试题 01.01. 判定字符是否唯一
2022-07-04 21:23:00 【Mr Gao】
面试题 01.01. 判定字符是否唯一
实现一个算法,确定一个字符串 s 的所有字符是否全都不同。
示例 1:
输入: s = “leetcode”
输出: false
示例 2:
输入: s = “abc”
输出: true
这题其实比较简单的,解题代码如下:
bool isUnique(char* astr){
int r[26];
int i;
for(i=0;i<26;i++){
r[i]=0;
}
i=0;
while(astr[i]!='\0'){
r[astr[i]-'a']++;
// printf("%d",)
if(r[astr[i]-'a']>=2){
return false;
}
i++;
}
return true;
}
}
边栏推荐
猜你喜欢

历史最全混合专家(MOE)模型相关精选论文、系统、应用整理分享

案例分享|金融业数据运营运维一体化建设
![[optimtool.unconstrained] unconstrained optimization toolbox](/img/ef/65379499df205c068ee9bc9df797ac.png)
[optimtool.unconstrained] unconstrained optimization toolbox

超详细教程,一文入门Istio架构原理及实战应用

【公开课预告】:视频质量评价基础与实践

VS2019 C# release下断点调试

MongoDB聚合操作总结

Why do you have to be familiar with industry and enterprise business when doing Bi development?

Application practice | Shuhai supply chain construction of data center based on Apache Doris

Bookmark
随机推荐
Learning breakout 3 - about energy
【活动早知道】LiveVideoStack近期活动一览
案例分享|金融业数据运营运维一体化建设
Flutter 返回按钮的监听
How was MP3 born?
At the right time, the Guangzhou station of the city chain science and Technology Strategy Summit was successfully held
Sorting and sharing of selected papers, systems and applications related to the most comprehensive mixed expert (MOE) model in history
Interpreting the development of various intelligent organizations in maker Education
GTEST from ignorance to proficiency (4) how to write unit tests with GTEST
Le module minidom écrit et analyse XML
应用实践 | 蜀海供应链基于 Apache Doris 的数据中台建设
哈希表(Hash Tabel)
ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start
开源之夏专访|Apache IoTDB社区 新晋Committer谢其骏
并列图的画法,多排多列
Methods of improving machine vision system
[leetcode] 17. Letter combination of telephone number
gtest从一无所知到熟练使用(4)如何用gtest写单元测试
Jerry's ad series MIDI function description [chapter]
Compréhension approfondie du symbole [langue C]