Hello programming lovers,
This question was asked in IIT Gandhinagar during M.Tech Admission interview.
The idea is simple, you have to merge two string.
for example :
String 1 - Apple
String 2 - Ball
then output should be :
ABpapllle
Example : 2
String 1 : Cat
String 2 : Doctor
output : CDaotctor
Try it before going for solution. The following code is written in Python. If you want you can convert it in Java, C++ or whatever your tools is . But if you write it please send it to me.
Best of Luck.
a="123456789"
b="abcdefghijkl"
mstr =""
alen = len(a)
blen = len(b)
loop = min(alen, blen)
for i in range(loop):
mstr += a[i]
mstr += b[i]
if(alen > blen) :
mstr += a[loop:]
else :
mstr += b[loop:]
print(mstr)
This question was asked in IIT Gandhinagar during M.Tech Admission interview.
The idea is simple, you have to merge two string.
for example :
String 1 - Apple
String 2 - Ball
then output should be :
ABpapllle
Example : 2
String 1 : Cat
String 2 : Doctor
output : CDaotctor
Try it before going for solution. The following code is written in Python. If you want you can convert it in Java, C++ or whatever your tools is . But if you write it please send it to me.
Best of Luck.
a="123456789"
b="abcdefghijkl"
mstr =""
alen = len(a)
blen = len(b)
loop = min(alen, blen)
for i in range(loop):
mstr += a[i]
mstr += b[i]
if(alen > blen) :
mstr += a[loop:]
else :
mstr += b[loop:]
print(mstr)
Comments
Post a Comment