subhedarnikhil
BAN USERvoid swap_int( int *a, int *b)
{
int temp=*a;
*a=*b;
*b=temp;
}
void remove_dup( int arr[],int num,int *size)
{
for(int i=0;i<(*size);i++)
{
if(arr[i]==num)
{
swap_int(&arr[i],&arr[*size]);
(*size)=(*size)-1;
}
}
}
int main()
{
int arr[]={1,2,4,5,6,7,8,354,345,12,7,89};
int size=(sizeof(arr)/sizeof(arr[0]))-1;
cout<<"\n\n\n\n";
remove_dup(arr,6,&size);
}
Hi KK the algorithm which ur using is kadanes algorithm..?
- subhedarnikhil December 23, 2011please check below code using hashing .suggestions are always accepted.
void print(char *str,int start,int end)
{
cout<<endl;
while(start<end)
{
cout<<str[start++];
}
}
void deleim_print(char *str,char *del)
{
char hash[256]={0,};
int start=0;
for(int i=0;del[i]!='\0';i++)
hash[del[i]]++;
for(int i=0;str[i];i++)
{
if(hash[str[i]]>=1)
{
print(str,start,i-1);
start=i+1;
}
}
}
i think mrn ur wrong using hash table we can retrive an element in o(1) complexcity but skip list uses the (logn) coplexcity. also using BST we can implement the skip list
- subhedarnikhil September 19, 2011if the values are negavive then we can't use the XOR operator .
- subhedarnikhil June 27, 2011Below is the code for the same
void middle(struct ndoe **ptr)
{
struct node *fast=(*ptr)
struct node *slow=(*ptr);
while(fast->next!=NULL && fast->next->next!=NULL)
{
slow=slow->next;
fast=fast->next->next;
}
printf("middle of the linked list is :%d",slow->info);
}
Hey parvez ,
- subhedarnikhil October 17, 2013after removing all the occurrences of the number array size will be changed right...??
so need to accept size as a pointer so it will be reflect in the main ()...