Is it possible to compare characters from a string and print out the position of the first unique one? Is there maybe something from the String class that can help me do this?
Pseudocode:
enter code here
String s = "ABC456";
int n = 2;
ArrayList<String> str = new ArrayList<>();
Map<String, Long> counts2 = new LinkedHashMap<String,
Long>();
for(String val : str){
long count = counts2.getOrDefault(val, 0L);
counts2.put(val, ++count);
}
for(String key: counts2.keySet()){
if(counts2.get(key)==1){
System.out.println(list.indexOf(key));
break;
}
}