Climbing the Leaderboard

  • + 0 comments

    C++ solution vector uniqueScores {}; vector result; int lastScore = ranked[0]; uniqueScores.push_back(lastScore); for(int i=1;i uniqueScores[mid]) { right = mid -1; } else { left = mid +1; } } int left_bound = (right>=0)? right:-1; int right_bound = (left< uniqueScores.size())?left:-1; if(left_bound == right_bound) { result.push_back(left_bound+1); } else if(left_bound == -1) { result.push_back(1); } else if(right_bound == -1) { result.push_back(uniqueScores.size()+1); } else { result.push_back(right_bound+1); } } return result;