2015年8月20日21:03:18 firstNotRepeatingChar 哈希表实现O(n)
2015-08-20 21:01
363 查看
<pre name="code" class="cpp">//for a char datetyp 4000 e,a 256 array hashtable . //looking for the first ,so wo should keep the sort char FirstNotRepeatingChar(char* pString) { if(pString == NULL) return '\0'; const int tableSize = 256; unsigned int hashTable[tableSize]; for(unsigned int i = 0; i<tableSize; ++ i) hashTable[i] = 0; char* pHashKey = pString; while(*(pHashKey) != '\0') hashTable[*(pHashKey++)] ++; pHashKey = pString; while(*pHashKey != '\0') { if(hashTable[*pHashKey] == 1) return *pHashKey; pHashKey++; } return '\0'; }
相关文章推荐
- 手工释放linux内存――/proc/sys/vm/drop_cache
- Hibernate 所有缓存机制详解
- 第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验学习笔记
- android 添加视频、图片、录音上传(二)
- [HDOJ4911]Inversion
- 电脑反应慢的原因
- NYOJ 709 异 形 卵(区域最大值,水题)
- [Linux]工作中常见的命令
- Win10下安装Genymotion出现virtualization engine not found的解决方案
- HDOJ 1241 Oil Deposits (DFS)
- C++那些细节--函数的默认参数
- poj 2406 Power Strings(kmp求一个串的重复子串)
- C语言中do...while(0)的妙用-避免goto
- OJ刷题---奇怪的分式
- hdu2066一个人的旅行【最短路dijkstra&&SPFA】
- Python|绝不乱入的靠谱书单
- golang-发送邮件
- 2.15 求二维数组的子矩阵的最大和
- 第K短路
- 九度oj 1103