Edit distance@run error

https://ide.codingblocks.com/s/53285
my code is working fine but it is giving wrong ans and run error while submitting

https://hack.codingblocks.com/contests/c/512/409

you are facing run time because you have created 2D vector of size 2001*2001 but you have increment m and n in function.

  • you are also doing an implementation mistake, string is 0 based indexed but you are using as it is 1 based, so add any variable at the beginning of stings and iterate in for loop with i=1 and j=1.

https://ide.codingblocks.com/s/53317

See this code and check the changes i have done.

Hit like if you get it!
Happy coding :smiley:

1 Like

why did u add ‘a’ at the beginning of both the strings?

Because code you have written in on 1 based indexing ( do a dry run with pen paper)
so to make string 1 based indexing a added a variable in the beginning.

Hit like if you get it!
Happy coding :smiley:

1 Like