Unique Characters

 Unique Characters 

 Problem Statement: 
The program must accept a string S as the input. The program must find the unique characters present in the string (remove duplicates) and print them in the order of their occurrence in the string S.
Note: At least one unique character will be present in the string S.

Boundary Condition(s):
1 <= Length of S <= 100

Input Format:
The first line contains the string S.

Output Format:
The first line contains the unique characters in S (in the order of their occurrence in S).

 Example Input/Output 1: 
 Input: 
Ethernet112

 Output: 
Ehrn2

Explanation:
The unique characters in the string "Ethernet112" are E, h, r, n and 2.
So they are printed in the order of their occurrence in the string "Ethernet112".
Hence the output is Ehrn2.

Example Input/Output 2:
Input:
lollipop

Output:
i

 Note: Max Execution Time Limit: 2000 millisecs 

 Solution: 

 Programming Language: C Language 

#include <stdio.h>
#include <stdlib.h>
int main() {
    char a[101];
    scanf("%s",a);
    int charc[128]={0};
    for(int i=0;a[i]!='\0';i++){
        charc[a[i]]++;
    }
    for(int i=0;a[i]!='\0';i++){
        if(charc[a[i]]==1){
            printf("%c",a[i]);
        }
    }
}
//Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Print Alphabets

Sort Number By Unit and Tenth Digits

Move Hundreds to End

Matrix Unit Digit Swap

Array Elements - Divisible by D

Next Multiple of X after N