Home > Blockchain >  How can I decide what the original text might be in c#. I get a couple of texts from the input and m
How can I decide what the original text might be in c#. I get a couple of texts from the input and m

Time:11-24

My problem is as follows: Problem details The input description, output description and sample test case is as follows input description,output description and a sample test case

Since it is assumed that the correct character is the one which is written in most of the copies, I tried to count the most occuring text. My code is as follows That is the remaining part of the code

But I still don't get the correct output. Any ideas

CodePudding user response:

The first solution that comes to mind is to make the input string into a char array.

Then count the number of times a character has appeared at the index i.

After that for each index get the most repeated character(# if there is none) and return it to output.

  • Indexes: 0 1 2 3 4 5 6 7

  • Input1: A B C D E F G H

  • Input2: A B C D E X X H

  • Input3: A B C V E F G E

Char counts for indexes:

0 -> 3A

1 -> 3B

2 -> 3C

3 -> 2D,1V

4 -> 3E

5 -> 2F, 1X

6 -> 2G, 1X

7 -> 2H, 1E

Output: ABCDEFGH

  • Related