Java Program To Find First Non Repeated Character | Java | Ashok IT

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 37

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

    🔥 Welcome to Ashok IT..!!
    👉 Register Here For Online Training : bit.ly/4dBYJbX
    👉 Follow us in Instagram : bit.ly/3jzEKl8
    👉 Follow Us in WhatsApp : bit.ly/49wCWje
    👉 Visit Our Website : ashokit.in/

  • @Ravikumar-gj6qw
    @Ravikumar-gj6qw 3 роки тому +2

    Ur way of explaining or teaching is excellent 👌😉bro superb 👌👍👏, nobody is there ...

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

    public class practicee {
    public static void main(String args[])
    {
    String s="AABCDBE";
    int count=0;
    char[] k =s.toCharArray();
    for (int i = 0; i < k.length; i++) {
    for (int j = 0; j < k.length; j++) {
    if (k[i]==k[j]) {
    count++;
    }

    }
    if (count==1) {
    System.out.println(k[i]);
    break;
    }
    count=0;
    }
    }
    }
    this is my approach

  • @YashSingh-xs5yj
    @YashSingh-xs5yj 4 місяці тому

    Collection approach is the best ❤

    • @ashokit
      @ashokit  3 місяці тому +1

      Thankyou so much.. 🔥 Please follow us in WhatsApp channel : bit.ly/49wCWje

  • @dipikasharma748
    @dipikasharma748 4 роки тому +17

    Shouldn't the map be LinkedHashMap so that it maintains the insertion order to correctly identify first non-repeated character?

    • @mishra1576
      @mishra1576 4 роки тому +5

      Yes it should be😊

  • @rajeevkalangi2472
    @rajeevkalangi2472 2 роки тому

    Thanks Bro. Your explanation is super cool.

  • @ajayghode3602
    @ajayghode3602 Місяць тому

    Thank you Sir.

    • @ashokit
      @ashokit  Місяць тому

      Thankyou so much..

  • @jagadeeshbaskaran4881
    @jagadeeshbaskaran4881 2 роки тому

    Excellent . Thanks sir

  • @jatinsharma3792
    @jatinsharma3792 11 місяців тому +4

    In hashMap the insertion order is not maintain, how can you be sure it will give your the First Non Repeated Char boss ????

    • @ashokit
      @ashokit  5 місяців тому

      please contact our admin team : +91 9985396677

    • @TechieToHelpYou
      @TechieToHelpYou 28 днів тому

      After finding frequency for every element then take another loop iterate thourgh loop index from 0 to string.length
      Then for each character check in the map wheather that character has 1 or not

  • @DanishAli-ql1es
    @DanishAli-ql1es 4 місяці тому

    Very nice explanation

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

      Thanks for liking

  • @kameshwaran6689
    @kameshwaran6689 2 роки тому

    Really superb

  • @Ravikumar-gj6qw
    @Ravikumar-gj6qw 3 роки тому

    Tq Ashok bro

  • @ram8705
    @ram8705 7 місяців тому

    My approach :
    String unique = "AABDCE";
    for (int i = 0; i < unique.length(); i++) {
    for (int j = i+1; j < unique.length(); j++) {
    if(unique.charAt(i) != unique.charAt(j)) {
    System.out.println("1st non repeating char is : "+unique.charAt(j));
    return;
    }
    }
    }

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

      🔥 Please follow us in WhatsApp channel : bit.ly/49wCWje

    • @eshwarmuruganti9758
      @eshwarmuruganti9758 2 місяці тому

      It won't work for all the cases it will print all the characters from given string expect

  • @kkiran-zk8ed
    @kkiran-zk8ed 3 роки тому +3

    You can use j=i+1

    • @alokkumar-pl6ds
      @alokkumar-pl6ds 2 роки тому +1

      same doubt

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

      I don't think j=i+1 would work because in that case first iteration A and A would be compared in second iteration A and b would be compared and thus compiler would declare A as the first non repeating character.I am also not sure.

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

      @@krishkhemani96 if we take j = i+1 then it will consider the last duplicate character as the first non-repeating character for eg It will consider 'A' of index 1 as a non-repeating character.

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

    using this collection approach it won't give correct output , if the non repeated occurs at the first position , for example input = "kaabcdbe" output should be k but it would give c.

  • @ganeshbodduaddasuryanitinb7811
    @ganeshbodduaddasuryanitinb7811 3 роки тому

    Using index Of method?

  • @DILEEPKUMAR-gp7ic
    @DILEEPKUMAR-gp7ic 2 роки тому

    It is coming last non repeated char we need first non repeated characters

  • @showdownx8276
    @showdownx8276 2 місяці тому

    Cant use HashMap here.

    • @ashokit
      @ashokit  2 місяці тому

      🔥 Please follow us in WhatsApp channel : bit.ly/49wCWje

  • @hchemlal
    @hchemlal 2 роки тому +3

    Your coding still needs some polishing, first approach you should have used j=i+1 and the second approach you should have used LinkedHashMap.

    • @anbuv.g.k495
      @anbuv.g.k495 2 роки тому

      Yeass bro and the hashmap does not maintain insertion order right? How he got the answer bro..!

    • @hchemlal
      @hchemlal 2 роки тому

      @@anbuv.g.k495 It will work 90% of the time, but in production setting you'll face reality.

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

      I don't think j=i+1 would work because in that case first iteration A and A would be compared in second iteration A and b would be compared and thus compiler would declare A as the first non repeating character.I am also not sure.