Cracking The Coding Interview 1.1
2024-10-11 19:56:30
//原文:
//
// 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;
}
最新文章
- WPF仿百度Echarts人口迁移图
- 如何在Eclipse中查看JDK的源代码
- Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use.解决办法
- 学习打造自己的DEBUG_NEW
- LINQ之select方法选择多个字段
- WinForms 使用Graphics绘制字体阴影
- android 的开源输入法介绍,及 自动触摸的实现方法
- synchronized关键字小结(一)
- ARM开发板系统移植-----kernel的编译
- java DI 框架spring(web)、Guice(web)、Dagger&;Dagger2(android)
- ubuntu cenots 禁止本地登陆
- 第二周 IP通信基础回顾
- 2019年IntelliJ IDEA 最新注册码,亲测可用(截止到2020年3月11日)
- 关于字符串的简单dp
- linux 查看系统资源使用情况:vmstat
- KNN算法的感受 1
- Floyd求最小环!(转载,非原创) 附加习题(原创。)HDU-1599
- day 43 mysql 学习 以及pymysql 学习
- 撩课-Mysql详解第3部分sql分类
- Java 序列化工具类
热门文章
- (转)winform之ListView
- php oracle数据库clob和nclob字段
- 图像识别 | AI在医学上的应用 | 深度学习 | 迁移学习
- 第十章 Call 和 Ret 指令
- LeetCode--429--N叉树的层序遍历
- p2693 Combination Lock
- IBM messed up *AGAIN* in their thinkpad: 0xA0000 ->; 0x9F000
- Android 如何更改一个 imageview的颜色
- RMQ 解决区间查询问题
- fiddler filter过滤+断点