#include "stdafx.h"
#include <algorithm>
#define MAX_LENGTH 500
void delDuplicate(char* pStr, int iStrlen)
{
int iLargeLabel = 0;
int iSmallLabel = 0;
int i0 = 0;
int ikey;
for(int i = 0; i < iStrlen; i++)
{
ikey = pStr[i] - 'A';
if(ikey < 26)
{
if( ((iLargeLabel >> ikey) & 1) == 0 )
{
iLargeLabel += 1<<ikey;
pStr[i0] = pStr[i];
i0++;
}
}
else
{
ikey = pStr[i] - 'a';
if( ((iSmallLabel >> ikey) & 1) == 0 )
{
iSmallLabel += 1<<ikey;
pStr[i0] = pStr[i];
i0++;
}
}
}
pStr[i0] = pStr[iStrlen];
}
int main()
{
char pStrInput[MAX_LENGTH];
scanf("%s", pStrInput);
int iLen = 0;
while(pStrInput[iLen++] != '\0')
continue;
iLen--;
if(iLen == 0)
printf("the string is empty\n");
else
{
delDuplicate(pStrInput, iLen);
printf("the new string is %s\n", pStrInput);
}
}
cracking the coding interview problem solution 1.3
原创
©著作权归作者所有:来自51CTO博客作者nicolin7的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Top 10 Algorithms for Coding Interview
The following are top 10 algorithms related topics for coding interviews. As understanding those concepts requires much more effort,re viewed fro
softwareEnginner Coding Interview top10 Java List

















