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

КОМЕНТАРІ • 38

  • @GurjeetSingh-zr7vj
    @GurjeetSingh-zr7vj Рік тому +12

    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

    • @nitishkumar-mj9tp
      @nitishkumar-mj9tp 9 місяців тому

      @GurjeetSingh-zr7vj ,Your code is small ,but it takes 8-10 minutes for me to understand. Thanks

    • @sruthimajhi5610
      @sruthimajhi5610 4 місяці тому

      she did that man, look at the else condition.

  • @saratdas8886
    @saratdas8886 6 місяців тому +7

    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

  • @nitishkumar-mj9tp
    @nitishkumar-mj9tp 9 місяців тому +1

    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.

  • @androiddeveloperlpu301
    @androiddeveloperlpu301 Рік тому +3

    For those code is not running write the condition of checking length of both the strings is not equal then return false

  • @amitgada21
    @amitgada21 Рік тому +6

    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

  • @MsArn3
    @MsArn3 Рік тому +9

    Please soom out, we cant barly see an intire line of code

  • @hustle_with_looser
    @hustle_with_looser 16 днів тому

    Literally you are good but in some video you jst make it more complex.

  • @shindeprem228
    @shindeprem228 8 місяців тому +8

    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

  • @KushSahu-jn9lf
    @KushSahu-jn9lf 11 годин тому

    Will not work for all the test cases

  • @etc3776
    @etc3776 16 годин тому

    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.

  • @tufguygaming
    @tufguygaming Рік тому +1

    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

  • @adityamishra1868
    @adityamishra1868 9 місяців тому +1

    explanation is good but they way of writting code is worst, u are placing cbraces before adding if or else

  • @amitchaurasia592
    @amitchaurasia592 8 місяців тому

    Can you check the below one
    abcs
    pqrb

  • @WHAGDEVARAKONDAVAISHNAVI
    @WHAGDEVARAKONDAVAISHNAVI Рік тому

    thank you mam.....for your explanation...................

  • @roopkumar2803
    @roopkumar2803 Рік тому

    very well explained ma'am

  • @sachinpatil1010
    @sachinpatil1010 Рік тому

    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;
    }

  • @hirahasan
    @hirahasan Рік тому

    check your solution with "asdvd" and "kkk"

    • @TechnosageLearning
      @TechnosageLearning  Рік тому

      It is returning false since these strings are not isomorphic strings

    • @suhasdevang9332
      @suhasdevang9332 Рік тому +1

      ​@@TechnosageLearninginstead coding in local ide do code in leetcode so that your code not running successfully for all the testcases

  • @androiddeveloperlpu301
    @androiddeveloperlpu301 Рік тому +2

    Map m=new HashMap();
    int n=s.length();
    if(s.length()!=t.length()){
    return false;
    }
    for(int i=0;i

  • @Ram-e2e
    @Ram-e2e 6 місяців тому

    why are you write the code as fast. It is not understandable. first teach slowly while code the program

    • @TechnosageLearning
      @TechnosageLearning  6 місяців тому

      Thanks for the review. Will keep that in mind in the upcoming videos

  • @DailyProg
    @DailyProg 3 місяці тому

    This solution is incorrect

  • @mhirroaceroyportillo875
    @mhirroaceroyportillo875 Рік тому +1

    I’m afraid this solution will fail given s = abdc t = abab

    • @TechnosageLearning
      @TechnosageLearning  Рік тому +1

      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..

    • @suhasdevang9332
      @suhasdevang9332 Рік тому

      ​@@TechnosageLearning but your code not running for all the testcase

  • @aapkikhushi4689
    @aapkikhushi4689 Рік тому

    Code ka last mai image dal do atleast

  • @pkshriram2530
    @pkshriram2530 Рік тому +9

    you are too fast mam, couldn't follow it 🥲