205. Isomorphic Strings

Input: s = "egg", t = "add"
Output: true
Input: s = "foo", t = "bar"
Output: false
Input: s = "paper", t = "title"
Output: true
  • 1 <= s.length <= 5 * 104
  • t.length == s.length
  • s and t consist of any valid ascii character.
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
hash = dict()
list_set=set()
for i in range(len(s)):
if s[i] not in hash:
if t[i] not in list_set:
hash[s[i]]=t[i]
list_set.add(t[i])
else:
return False
else:
if(hash[s[i]]!=t[i]):
return(False)
return(True)

--

--

--

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Restore and Recovery the dropped tablespace in Oracle (RMAN-20202)

Creating API Driver API Profiles

Pieces of advice I would give to someone just beginning their journey with software development…

Steps to Setup Firebase to your Flutter Application

Exception Handling

🔥 #Roseon is proud to announce that #Swap feature has been released on our app.

Store Git Credentials Encrypted

knoldus-advt-sticker

Laravel One to Many relationships with CRUD example

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dhanarajappu

Dhanarajappu

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.

More from Medium

What is return load in fleet management?

Software Driven Labor

119. Pascal’s Triangle I & II