Problem Statement | |||||||||||||
| There are two candidates campaigning to be president of a country.
From newspaper polls, it is clear what percentages of people plan to vote for each candidate in each state.
Candidate 1 wants to campaign in one last state, and needs to figure out which state that should be.
You are given a String[] likelihoods, each element of which corresponds to a state. Each element consists of the characters '1' and '2', where '1' represents some number of votes for candidate 1, and '2' represents votes for candidate 2 (in each element every character represents the same number of votes). You are to return an int representing the 0-based index of the state where the lowest percentage of people are planning on voting for candidate 1 (lowest percentage of '1' characters in that element of the input). If there are multiple such states, return one with the lowest index in likelihoods. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | likelihoods will contain between 1 and 50 elements inclusive. | ||||||||||||
| - | Each element of likelihoods will contain between 1 and 50 characters inclusive, and each character will be '1' or '2'. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
| 4) | |||||||||||||
| |||||||||||||