English, asked by deshpandepragati03, 4 months ago

program to find non repeated chars in a given string​

Answers

Answered by kantasireesha
0

Answer:

Given a string, find its first non-repeating character

Make a hash_map which will map the character to there respective frequencies.

Traverse the given string using a pointer.

Increase the count of current character in the hash_map.

Now traverse the string again and check whether the current character hasfrequency=1.

If the frequency>1 continue the traversal.

this is the answer

hope it si helpful

Answered by likhithagadagoju
0

Answer:

Program to find the first non-repeating character in a string

1. /* C program to find first non-repeating character */

2. #include<stdlib.h>

3. #include<stdio.h>

4. #define NO_OF_CHARS 256.

​ 5.

6. int *get_char_count(char *str)

7. {

8. int *count = (int *)calloc(sizeof(int), NO_OF_CHARS);

Program to find the first non-repeating character in a string is discussed here. Given a string, the task is to find the first non-repeating character in the string.

Input and Output format:

The first line of the input consists of a string.

Sample Input 1:

teeterson

Sample Output 1:

r

Sample Input 2:

charactercharacter

Sample Output 2:

All characters are repetitive

Algorithm to find the first non-repeating character in a string

Input the string from the user.

Start traversing the string using two loops.

Use the first loop to scan the characters of the string one by one.

Use the second loop to find if the current character is occurring in the latter part if the string or not.

If it is not occurring, print that character.

Else, continue traversing.

Similar questions