3.去除字符串中重复字符,保证每个字符只出现一次

//Design an algorithm and write code to remove the duplicate characters in a string 
//without using any additional buffer NOTE: One or two additional variables are fine 
//	An extra copy of the array is not
#include 
using namespace std;

//void move(char *s)
//{
//	while(*s)
//	{
//		*s =*(s+1);
//		s++;
//	}
//}
bool remove(char s[])
{
	if (s==NULL) return false;
	int n =strlen(s);
	if (n<2)return false;
	int m =0;
	for (auto i =0;i0) 
		{
			for(auto j= i;s[j]!=NULL;j++)
				s[j] =s[j+1];
			i--;
		}
		m |=(1<


你可能感兴趣的:(面试)