Rank Common Translation Mistakes
Problem statement
Learners submit translations of the same sentence. You are given submissions, where every row contains the translated words in their sentence positions.
For each position independently, find its greatest word frequency. Every word tied for that greatest frequency is considered correct at that position. Every occurrence of any other word at that position is a mistake.
Aggregate the number of mistaken occurrences for each word across all positions and submissions. Return each distinct mistake word exactly once, ordered by decreasing mistake frequency. When two mistake words have the same frequency, order them alphabetically.
Function
countingMistakes(submissions: String[][]) → String[]Examples
Example 1
submissions = [["your","bear","drinks","beer"],["your","bear","eats","beer"],["the","bear","drinks","beer"]]return = ["eats","the"]At position 0, your is modal and the is one mistake. At position 2, drinks is modal and eats is one mistake. Both mistake frequencies are 1, so alphabetical order places eats before the.
Example 2
submissions = [["your","bear","drinks","beer"],["your","bear","eats","beer"],["the","bear","drinks","beer"],["your","bear","the","beer"]]return = ["the","eats"]The word the is mistaken once at position 0 and once at position 2, for a total of 2. The word eats is mistaken once, so the appears first.
Constraints
1 <= submissions.length <= 1000.1 <= submissions[i].length <= 100, and every submission has the same length.- Every word has length from
1through30. - Words contain only lowercase letters
athroughzand digits0through9. - The same word may occur more than once in one submission.