Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

first none duplicated char

import java.util.Scanner;

public class FirstDuplicate
{
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args)
    {
        System.out.println("Enter random chars");
        String s = new String(scanner.nextLine());
        findTheFirstDublicate(s);

    }
    private static boolean findTheFirstDublicate(String s)
    {
        int[] arr = new int[26];

        for(int i=0 ; i<s.length() ; ++i)
        {
          int c =  s.charAt(i)-'a';
          ++arr[c];
        }
        pint(arr);
        return false;
    }

    private static void pint(int[] arr){
        int i = 0 ;
        while(i < arr.length){
            if(arr[i] == 1){
                System.out.println("First none duplicated letters "+((char)(i+'a')));
            }
            ++i;
        }
    }
}
 
PREVIOUS NEXT
Tagged: #duplicated #char
ADD COMMENT
Topic
Name
8+9 =