在一个字符串中找到第一个只出现一次的字符,要求时间复杂度O(n)

2014-11-24 00:12:12 · 作者: · 浏览: 4
 // 在一个字符串中找到第一个只出现一次的字符.cpp : Defines the entry point for the console application.   
//   
//利用hash表,记录每一个字符出现的次数   
//char占8个位,字符的最大可能数是2^8=256   
#include "stdafx.h"   
#include    
using namespace std;  
const int TableSize=256;  
char FindFirstNoRepeateChar(char *str)  
{  
    unsigned int hashTable[TableSize];  
    for(int i=0;i