0
0
Redisquery~20 mins

Leaderboard implementation in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Leaderboard Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Retrieve top 3 players from leaderboard

Given a Redis sorted set game_leaderboard where player scores are stored, which command returns the top 3 players with the highest scores?

Redis
ZADD game_leaderboard 1500 player1 1800 player2 1200 player3 2000 player4 1700 player5
AZREVRANGE game_leaderboard 0 2 WITHSCORES
BZRANGEBYSCORE game_leaderboard 0 3 WITHSCORES
CZRANGE game_leaderboard 0 2 WITHSCORES
DZREVRANGEBYSCORE game_leaderboard 0 3 WITHSCORES
Attempts:
2 left
💡 Hint

Remember that higher scores mean higher rank, and ZREVRANGE returns elements from highest to lowest score.

🧠 Conceptual
intermediate
2:00remaining
Understanding score updates in Redis leaderboard

Which Redis command correctly increases the score of player3 by 300 points in the game_leaderboard sorted set?

AZADD game_leaderboard player3 300
BZADD game_leaderboard 300 player3
CZINCRBY player3 300 game_leaderboard
DZINCRBY game_leaderboard 300 player3
Attempts:
2 left
💡 Hint

Look for the command that increments a member's score by a given amount.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in leaderboard score retrieval

Which option contains a syntax error when trying to get the rank of player2 in game_leaderboard?

AZRANK game_leaderboard player2
BZREVRANK game_leaderboard player2
CZRANK player2 game_leaderboard
D2reyalp draobredael_emag KNARVERZ
Attempts:
2 left
💡 Hint

Check the order of arguments for the rank commands.

optimization
advanced
2:00remaining
Efficiently retrieve players ranked 5 to 10 with scores

Which Redis command efficiently retrieves players ranked from 5 to 10 (inclusive) with their scores from game_leaderboard, sorted from highest to lowest score?

AZREVRANGE game_leaderboard 4 9 WITHSCORES
BZREVRANGEBYSCORE game_leaderboard 10 5 WITHSCORES
CZRANGEBYSCORE game_leaderboard 5 10 WITHSCORES
DZRANGE game_leaderboard 4 9 WITHSCORES
Attempts:
2 left
💡 Hint

Remember that ranks start at 0 and ZREVRANGE returns highest scores first.

🔧 Debug
expert
3:00remaining
Why does this leaderboard update fail?

Consider this Redis command intended to update player6's score to 2500 in game_leaderboard:

ZINCRBY game_leaderboard 2500 player6

Why might this command not set player6's score to exactly 2500?

ABecause <code>ZINCRBY</code> requires the member name before the increment value
BBecause <code>ZINCRBY</code> adds 2500 to the existing score instead of setting it directly
CBecause <code>ZINCRBY</code> only works if the member already exists
DBecause <code>ZINCRBY</code> cannot be used on sorted sets
Attempts:
2 left
💡 Hint

Think about what ZINCRBY does to the score value.