Hamming
Practice
3.9 (9 votes)
Algorithms
Easy
String manipulation
Problem
44% Success 2703 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

It is Raful's birthday, and his friends gave him N strings of length M. But he is not happy, because he wants only one beautiful string S.

His friends are upset now. You, as the best programmer in Lalalandia, decided to help them.

The string S is considered beautiful only when the sum of the Hamming distances between it and each of the N strings is minimal. If there exist several such strings, print out the lexicographically smallest one.

Input format

The first line of the input contains two integers N, M - number of strings and their lengths respectively.

Then N lines follow, each containing a string \(s_i\) (\(1 \le i \le N\)), each consists of lowercase English letters.

Output format

The only line of the output should contain the string S.

Constraints:

\(1 \le N * M \le 100000\)

Note

You can learn more about Hamming distance here:

https://en.wikipedia.org/wiki/Hamming_distance

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
16 votes
Tags:
AlgorithmsString SearchingString Algorithms
Points:20
24 votes
Tags:
ApprovedEasyString Manipulation
Points:20
42 votes
Tags:
Data StructuresEasySortingString Manipulationapproved