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

preview_player
Показать описание

** For Online Training ► Call: +91-6301921083

Subscribe to our channel and hit the bell 🔔🔔🔔 icon to get video updates.

💡 Visit Our Website

💡 About Ashok IT :

Ashok IT is the No.1 quality training institute in India for the candidates who want to build their future in Information Technology. We are into online training, class room training, corporate training and one to one training with more passion and dedication. Ashok IT aims in providing best quality realtime oriented trainings on C, C++, Java, Spring , Spring REST, Spring Cloud, Microservices, Python, DJango, .Net, Angular, React JS, Salesforce, , Testing, Android, Docker, Kubernates, Manual Testing, Selenium and Digital Marketing.

-----------------------------------------------------------------------------------

💡 Our Online Training Features

🎈 Training with Real-time Working Professionals
🎈 Industry Matching use cases
🎈 Live Coding
🎈 Real-time Environment
🎈 Class Notes
🎈 Doubts Clarifications in Each Session

-----------------------------------------------------------------------------------

💡 Contact details:

☎ WhatsApp Number: +91-6301921083
Рекомендации по теме
Комментарии
Автор

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

rptech
Автор

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

Ravikumar-gjqw
Автор

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

dipikasharma
Автор

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

jatinsharma
Автор

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

ram
Автор

Thanks Bro. Your explanation is super cool.

rajeevkalangi
Автор

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.

moumajhi
Автор

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

DILEEPKUMAR-gpic
Автор

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

hchemlal