面试题 01.01. 判定字符是否唯一

阅读 41

2022-09-03


Leetcode ​​面试题 01.01. 判定字符是否唯一​​

class Solution {
public:
bool isUnique(string astr) {
int lowerLetters[26] = { 0 };
for (char& ch : astr)
{
int ret = ch - 'a';
++lowerLetters[ret];
}
for (int i = 0; i < 26; i++)
{
if (lowerLetters[i] > 1)
{
return false;
}
}
return true;
}
};

面试题 01.01. 判定字符是否唯一_leetcode


相关推荐

精彩评论(0)

0 0 举报