Domanda di colloquio di DraftKings

Coding Question: Given an array of fantasy entry objects: EntryID | userName | TotalScore | CompetituionRank EntryID int UserName String TotalScore Int CompeitionRank Integer All fields are poplated except compeition rank is set to NULL instance variables are public for ease the goal is to assign each user a rank, and in the result of a tie assign tieing users the same rank and skip the next rank. Example: 100, 89,89,71,50 would be ranked: 1,2,2,4,5 (3 is skipped since 2 and 3 tied) input: Entry[] entries

Risposta di colloquio

Anonimo

6 ott 2015

with a limited amount of time (20 minutes to talk,code,and discuss) and not wanted to google things, I wasnt made aware that I could sort the entry[] array by overriding its comparable method. this is the correct answer. Collections.sort(entries, new comparator()) { public int compare(entry e1, entry e2) { return Integer.compare(e1.TotalScore, e2.totalScore);

2