//原文:
//
// Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
//
// 使用一个数组来记录该字符是否出现过,这里假定只为小写字母。
#include <iostream>
using namespace std;
bool isUnique(const char *str)
{
int size = strlen(str);
bool isUnique[26] = {false};
for (int i = 0; i < size; i++)
{
int k = str[i] - 'a';
if (isUnique[k])
{
return false;
}
else
isUnique[k]=true;
}
return true; }
int main()
{ char s[] = "seoklncsz";
cout << isUnique(s) << endl;
return 0;
}


最新文章

  1. WPF仿百度Echarts人口迁移图
  2. 如何在Eclipse中查看JDK的源代码
  3. Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use.解决办法
  4. 学习打造自己的DEBUG_NEW
  5. LINQ之select方法选择多个字段
  6. WinForms 使用Graphics绘制字体阴影
  7. android 的开源输入法介绍,及 自动触摸的实现方法
  8. synchronized关键字小结(一)
  9. ARM开发板系统移植-----kernel的编译
  10. java DI 框架spring(web)、Guice(web)、Dagger&amp;Dagger2(android)
  11. ubuntu cenots 禁止本地登陆
  12. 第二周 IP通信基础回顾
  13. 2019年IntelliJ IDEA 最新注册码,亲测可用(截止到2020年3月11日)
  14. 关于字符串的简单dp
  15. linux 查看系统资源使用情况:vmstat
  16. KNN算法的感受 1
  17. Floyd求最小环!(转载,非原创) 附加习题(原创。)HDU-1599
  18. day 43 mysql 学习 以及pymysql 学习
  19. 撩课-Mysql详解第3部分sql分类
  20. Java 序列化工具类

热门文章

  1. (转)winform之ListView
  2. php oracle数据库clob和nclob字段
  3. 图像识别 | AI在医学上的应用 | 深度学习 | 迁移学习
  4. 第十章 Call 和 Ret 指令
  5. LeetCode--429--N叉树的层序遍历
  6. p2693 Combination Lock
  7. IBM messed up *AGAIN* in their thinkpad: 0xA0000 -&gt; 0x9F000
  8. Android 如何更改一个 imageview的颜色
  9. RMQ 解决区间查询问题
  10. fiddler filter过滤+断点