Isomorphic Strings | LeetCode problem 205
Вставка
- Опубліковано 23 січ 2025
- Isomorphic Strings
Leetcode problem number 205
Solution in JAVA
JAVA interview programming playlist:
• Interview Programming ...
Linkedin: / amrita-bala-a2b79460
#java #interviewquestions #leetcode
It is an partial algorithm , The code didn't check condition weather the used char is again used or not, if it is used we do not say the strings are isomorphic.
For Resolving - we have to use hashset which contains only those char who used only once.
code -
class Solution {
public boolean isIsomorphic(String s, String t) {
HashMap map = new HashMap();
HashSet check = new HashSet();
for(int i=0;i
@GurjeetSingh-zr7vj ,Your code is small ,but it takes 8-10 minutes for me to understand. Thanks
she did that man, look at the else condition.
the indentation and the brackets opening and closing are not taken care of , and also this code is partially complete , this doesn't pass all test cases
To the point video, very nice for entry-level experience people(1-2 yr), they don't want everything from basics which takes more time.
For those code is not running write the condition of checking length of both the strings is not equal then return false
Please zoom out the page little bit cannot see the above code lines when explaining or writing code. Keep the zoom in such a way that whole code logic is visible everytime
Sure..Will take care next time
Please soom out, we cant barly see an intire line of code
Literally you are good but in some video you jst make it more complex.
class Solution {
public boolean isIsomorphic(String s, String t) {
if(s.length()!=t.length()) return false;
HashMap hm = new HashMap();
for(int i=0 ; i
🙏
thanks
@@rishikanth4519 👍
@@kathakalisaha9735 👍
Will not work for all the test cases
Doesn't work for String s="badc";
String t="baba";
Because the condition says two characters of s cannot map to the same character of t.
I had to use two hashmaps to make it work.
This is the Code beats 100% users in C++
class Solution {
public:
bool isIsomorphic(string s, string t) {
if(s.size()!=t.size()){
return false;
}
int hash[256]={0}; // mapping of characters from string s
int isMapped[256]={0}; // ensures that mapping goes to which of the word in t
for(int i=0;i
explanation is good but they way of writting code is worst, u are placing cbraces before adding if or else
Can you check the below one
abcs
pqrb
thank you mam.....for your explanation...................
very well explained ma'am
The Above solution seems to be not passing for all the tests....
Please refer below solution , It works
s = "foo" t="bar"
1) sToT['f']= b and tToS['b'] = f
2) sToT['o']= a and tToS['a'] = o
3) sToT['o']= a and tChar = r
public bool IsIsomorphic(string s, string t) {
char[] sTOT = new char[256];
char[] tTOS = new char[256];
for (int i = 0;i< s.Length;i++)
{
char sChar = s[i];
char tChar = t[i];
if (sTOT[sChar] ==0 && tTOS[tChar] == 0)
{
sTOT[sChar] = tChar;
tTOS[tChar] = sChar;
}else if(sTOT[sChar] != tChar)
{
return false;
}
}
return true;
}
check your solution with "asdvd" and "kkk"
It is returning false since these strings are not isomorphic strings
@@TechnosageLearninginstead coding in local ide do code in leetcode so that your code not running successfully for all the testcases
Map m=new HashMap();
int n=s.length();
if(s.length()!=t.length()){
return false;
}
for(int i=0;i
why are you write the code as fast. It is not understandable. first teach slowly while code the program
Thanks for the review. Will keep that in mind in the upcoming videos
This solution is incorrect
I’m afraid this solution will fail given s = abdc t = abab
It would return false...since these two strings are not isomorphic .."No two characters may map to same character"
But in this case..a-->a and d-->a so it should return false only..
@@TechnosageLearning but your code not running for all the testcase
Code ka last mai image dal do atleast
Git ka url dia hai..Usme sare codes hai..You can try it out..
you are too fast mam, couldn't follow it 🥲
Will try to slow the pace in upcoming videos
See at slow speed 😂