Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Letter count You are playing a game of Letter count with your family. Here each member writes a word. Each word is rated on
Letter count You are playing a game of Letter count with your family. Here each member writes a word. Each word is rated on a scale of 0 to 26. The rating is according to the number of letters in the word that have occurred only once in the word. You are given an integer N where N denotes the number of family members. You are given an array of string words where words[i] denotes word written by ith family member. Task Return the word with the highest rating. If there is more than one word with the same rating then return the one that comes first lexicographically. Example Assumptions N = 2 worde earthl N = 2 words = [heyy, hackerearth] Approach 1. heyy - it has a rating 2 because [h, e] have only 1 occurrence in the word 2. hackerearth - it has a rating 3 because [c, k, t ] have only 1 occurrence in the word Therefore return hackerearth. Function description Complete the Solve() function provided in the editor below that takes the following arguments and returns return the word with the highest rating. If there is more than one word with the same rating then return the one that comes first lexicographically. N: Represents the total number of family members words: Represents the array of strings that contains the words written by family members Input format Input format The first line contains an integer N denoting the total number of family members. Next, the N line contains the words. Output format Return the word with the most distinct letters. If there is more than one word with the same distinct word count then return the one that comes first lexicographically. Constraints 1 Explanation 1. once - it has a rating 4 because [o, n, c, e ] have only 1 occurence in the word 2. three - it has a rating 3 because [t, h, r] have only 1 occurence in the word 3. sorry - it has a rating 3 because [s, o, y ] have only 1 occurrence in the word The following test cases are the actual test cases of this question that may be used to evaluate your submission. Sample input 1 > Sample output 1 boarding 4 boarding kevin equalizers sphaeriidae Sample input 2 Sample output 2 3 trap unhorizontal gaet unhorizontal Sample input 3 > Sample output 3 1 gowan gowan Sample input 4 Sample output 4 M Sample input 4 [> Sample output 4 11 omissus teethbrush electrocautery shriek charmfully bookbinder isosaccharic undubious pericles View more Sample input 5 [> 13 strobiline noncognitive drumble quadratrix pentavalence cladosporium triweeklies unmoldable contractor View more charmfully Sample output 5 cladosporium W Sample input 6 [> Sample output 6 unoptimistically 20 evolved ventriloquise penalities linguidental overhold cancellate fidalgo cottonmouth mangiest View more Sample input 7 > Sample output 7 30 riddlers impliable ravished monopsony shahi counterfeited fardel eulogiser rancelmen View more schizopelmous W Sample input 8 > Sample output 8 100 unmindfulness frize arean couponed strangleweed skainsmate haemangioma educ autographometer View more housewarming Sample input 9 Sample output 9 50 clubridden gynodioecism biolinguistics glacification doggier craps gongman unforcedness adverbiality View more chowdering Sample input 10 > Sample output 10 stylomandibular 100 slatternness interchannel heathendom felspathose illegitimacy largest malacca mutuals statured View more Note: Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement. Limits Time Limit: 1.0 sec(s) for each input file Memory Limit: 256 MB Source Limit: 1024 KB Scoring Score is assigned if any testcase passes Allowed Languages Java, Java 8, Java 14
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started