Code

mail@pastecode.io avatar
unknown
php
2 years ago
418 B
1
Indexable
Never
function climbingLeaderboard($ranked, $player) {
    // Write your code here
    $sorted_array = [];
    $ranked_unique = array_unique($ranked);
    foreach($player as $value) {
        $ranked_unique[] = $value;
        $new_order = array_unique($ranked_unique);
        rsort($new_order);
        $index = ( array_search($value, $new_order) + 1 );
        $sorted_array[] = $index;
    }
    return $sorted_array;
}