What is the significance of ("") before join method?? What I know is that we use "".join. But here the code is working fine if though ("") is used. Someone please explain.
("").join([map_s_to_t[s[i]] for i in range(len(s))])
Following is my whole code...
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
if len(set(s)) != len(set(t)):
return False
# Create a mapping of chars from s -> t
map_s_to_t = { s[i]: t[i] for i in range(len(s)) }
# Create a new string by replacing the chars in s with t
s_replaced_with_t = ("").join([map_s_to_t[s[i]] for i in range(len(s))])
# if the replaced string is same as t , then True else False
return(s_replaced_with_t == t)