algorithm - How to check if two strings can be made equal by using recursion? -


i trying practice recursion, @ moment don't quite understand well...

i want write recursive boolean function takes 2 strings arguments, , returns true if second string can made equal first replacing letters special character.

i'll demonstrate mean:

let s1 = "hello", s2 = "h%lo", '%' special character.

the function return true since '%' can replace "el", causing 2 strings equal.

another example:

let s1 = "hello", s2 = "h%l".

the function return false since 'o' lacking in second string, , there no special character can replace 'o' (h%l% return true).

now problem isn't writing code, understanding how solve problem in general, don't know begin.

if guide me in right direction grateful, using english words, i'll try translate code (java)...

thank you.

so relatively easy in python. method chose put first string ("hello") array iterate on second string ("h%lo") comparing elements in array. if element in array i.e. 'h', 'l', 'o' pop array. resulting array ['e','l']. special character can found element not exist in initial array.

one can substitute special character joined array "el" in string , compare first string.

in first case give "hello" == "hello" -> true in second case give "hello" == "helol" -> false

i hope helps , makes sense.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -