Solve using python

The City of Wonderland is under attack by an unknown virus. There are twenty six types of people who reside in the city of Wonderland i.e every person in the city belongs to any one of the types from a - z.

Many people have got infected by the virus and are fighting for their lives. Scientists have studied the virus and its impact on different types of people. After their study, they found that the virus is unable to cause damage to any of the people who belong to the type which are maximum in the city.

For example - If in the city, the maximum people belong to the type b, then all b types of people will be safe from the virus.

Scientists want to know the type for which the people are maximum so that they can safeguard them and also develop vaccination as an antidote to the virus which will provide immunity to other people. They are short of time and therefore need your help in determining the type for which the people are maximum in the city.

Note: If there are more than one type of people with equal maximum then the type with lesser ASCII value will be considered.

Can you help the Scientists in saving the city ?

Input Format
The first line of input consists of number of test cases, T.

The second line of each test case consists of a string representing the type of each individual person in the city.

1<= T <=10

1<= |string| <=100000

Output Format
For each test case, print the required output in a separate line.

Sample TestCase 1
Test Case 1: There are 2 q types of people rest all are present alone.

Test Case 2: There are 2 y and 2 z types of people. Since the maximum value is same, the type with lesser Ascii value is considered as output. Therfore, y is the correct type.
Time Limit(X):
0.50 sec(s) for each input.
Memory Limit:
512 MB
Source Limit:
100 KB

for _ in range(int(input())):
  list = input()
  arr = [0]*26
  for i in list:
  maxi = max(arr)
  print(chr(arr.index(maxi) + 97))

This is the Solution

1 Like


Error bro. Code is wrong. Slove using examples!

:joy: Honestly I have no clue what the OP meant.

It is working without errors in my local IDE and also working on ideone, please provide me the link of the question so i can investigate further
Note: Iā€™m using python 3.6

getting error
for _ in range(int(input())):
IndentationError: expected an indented block

Hi @wahida_123,

Can you help me in solving this puzzle.
Today is the last day my one test case is only passed but rest are failing.
I am sharing my code in java:
import java.util.
public class CandidateCode {

public static void main(String args[] ) throws Exception {

    //Write code here
//Write code here
        Scanner in = new Scanner(;
    int a;
    a = in.nextInt();
    String s2;
    String s3;
   for(int i=0;i<=a;i++){
    //  in.nextLine();
   s2 = in.nextLine();
char[] arr = s2.toCharArray(); 


static char firstRepeating(char str[])
// Creates an empty hashset
HashSet h = new HashSet<>();

    // Traverse the input array from left to right 
    for (int i=0; i<=str.length-1; i++) 
        char c = str[i]; 

        // If element is already in hash set, update x 
        // and then break 
        if (h.contains(c)) 
            return c; 

        else // Else add element to hash set 

    return '\0';