Must be written in JavaScript. 1. [Problem Description] Some friends decided to get together and play a game. The game r
Posted: Thu Jul 14, 2022 2:17 pm
Must be written in JavaScript.
1.[Problem Description]
Some friends decided to get together and play agame.
The game rules are as follows. N members are dealt acard of the same number, only two are dealt a card of a differentnumber.
There are at least 5 members, and there are 2 mafiaunconditionally in every game.
In this case, find the index of the mafia member andprint them out in ascending order.
For example, given array members are [4, 4, 10, 4, 10],
Of the 5 members, the member with 10 cards is the mafiaand the result we need to print is [2, 4].
[Restrictions]
- Array members contain at least 5 elements.
- All elements of the array members are positive.
- Mafia always has 2 players.
[Input format]
-array members are given.
[Output Format]
- Returns an array containing the indices of 2 mafia inascending order.
//
function solution(members) {
var answer = [];
return answer;
}
//
1.[Problem Description]
Some friends decided to get together and play agame.
The game rules are as follows. N members are dealt acard of the same number, only two are dealt a card of a differentnumber.
There are at least 5 members, and there are 2 mafiaunconditionally in every game.
In this case, find the index of the mafia member andprint them out in ascending order.
For example, given array members are [4, 4, 10, 4, 10],
Of the 5 members, the member with 10 cards is the mafiaand the result we need to print is [2, 4].
[Restrictions]
- Array members contain at least 5 elements.
- All elements of the array members are positive.
- Mafia always has 2 players.
[Input format]
-array members are given.
[Output Format]
- Returns an array containing the indices of 2 mafia inascending order.
//
function solution(members) {
var answer = [];
return answer;
}
//