Must be written in JavaScript. 1. [Problem Description] Some friends decided to get together and play a game. The game r

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Must be written in JavaScript. 1. [Problem Description] Some friends decided to get together and play a game. The game r

Post by answerhappygod »

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;
}
//
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply