saran87
BAN USERBy making post increment operator to pre increment in the first while worked. Don't know what is the reason exactly.
#include<iostream>
using namespace std;
char * mystcat(char *,char *);
char *q=new char[100];
int main()
{
char st1[100]="abcde";
char st2[100]="ghijh";
char *p;
p= mystcat(st1,st2);
cout<< p;
system("pause");
return 0;
}
char * mystcat(char * st1,char * st2)
{
char *q =st1;
if(st1=='\0'&&st2=='\0')
return st1;
else
while (*++st1);
while(*st1++ = *st2++ );
return q;
}
By making post increment operator to pre increment in the first while worked. Don't know what is the reason exactly.
#include<iostream>
using namespace std;
char * mystcat(char *,char *);
char *q=new char[100];
int main()
{
char st1[100]="abcde";
char st2[100]="ghijh";
char *p;
p= mystcat(st1,st2);
cout<< p;
system("pause");
return 0;
}
char * mystcat(char * st1,char * st2)
{
char *q =st1;
if(st1=='\0'&&st2=='\0')
return st1;
else
while (*++st1);
while(*st1++ = *st2++ );
return q;
}
You can use a hashTable to solve this problem.
- saran87 October 30, 2014Push all the 'A' object's with size as their keys. Then for each 'B' object, check if size of the object exists in HashTable.
RunTime : (Number of A objects + Number of B objects)
Memory: (Number of A objects)