Question: Write a function in C: Void findMinDistance(char *inputString); This function should find a repeated character in the input string with the minimum distance between two

Write a function in C:

Void findMinDistance(char *inputString);

This function should find a repeated character in the input string with the minimum distance between two consecutive occurrences.

Lets see a few examples:

ex1)

For input string:

Hi there, how is it going?

Output should be:

Repeated char = e, min distance = 1

This is because there are two es in this string which are separated by one character (there). And there is no other repeated character with a smaller distance.

ex2)

For input string:

Hello there, how is it going?

Output should be:

Repeated char = l, min distance = 0

ex3)

For input string:

123

Output should be:

No repeats found!

Notes:

  1. If there are multiple characters with the same minimum distance, outputting anyone is enough. For example: Hello there! Nice to meet you.. Both e and l have a distance of 0.

  2. The space character (and punctuations) could also potentially be the output.

  3. You should not use any other functions (in string.h, etc) that we havent covered.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!