Skip to content

Looking for best solution of HackerRank project. #37044

Discussion options

You must be logged in to vote

That is my answer. I hope it would be help to you.

const givenArr = ["Harry:-2", "Robbie:3", "Alexandra:3", "Michelle:4", "Malcom:2", "Susan:2", "Ellen:2", "Robbie:2", "Philip:2", "Max:1", "Marilin:-4", "Michelle:-3", "Richard:5", "Malcom:3", "Ellen:3", "Philip:-2", "Susan:-7", "Harry:-1", "Robbie:4", "Alexandra:-1", "Malcom:3", "Richard:2", "Marilyn:-2", "Michelle:-2", "Susan:2", "Philip:1", "Richard:5","Marilyn:3", "Harry:3"];

let uniqueUsers = []

givenArr.sort().map(ele => {
const key = ele.split(":")[0];
const value = Number(ele.split(":")[1]);
let searchedUsers = uniqueUsers.filter(user => {
return String(Object.keys(user)) === key
}) ;
if(searchedUsers.length > 0) {
searchedUsers[0]…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@MacarioLee
Comment options

Answer selected by MacarioLee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment