I have a recursive function in python like this
def recon(i,j):
if i == 0 or j == 0:
return []
elif x[i-1] == y[j-1]:
return recon(i-1,j-1) + [x[i-1]]
elif table[i-1,j] > table[i,j-1]:
return recon(i-1,j)
else:
return recon(i,j-1)
I am trying to rewrite this in c++, but the problem is the line
return recon(i-1,j-1) + [x[i-1]]
I trid to do this is c++, but it dosent compile, is there any way to concatenate arrays like python and return them.
Not with arrays. But you can do this with vectors.
You could to something similar with dynamically allocated memory, but it’s easier to use vectors.