0
0
Redisquery~10 mins

Top-N queries in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the top 3 scores from the sorted set 'game_scores'.

Redis
ZREVRANGE game_scores 0 [1] WITHSCORES
Drag options to blanks, or click blank then click option'
A4
B3
C2
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as stop index returns 4 elements, not 3.
Using -1 returns all elements, not top 3.
2fill in blank
medium

Complete the code to get the top 5 scores in descending order from 'game_scores'.

Redis
ZREVRANGE game_scores 0 [1] WITHSCORES
Drag options to blanks, or click blank then click option'
A4
B5
C3
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 5 as stop index returns 6 elements.
Using ZRANGE instead of ZREVRANGE returns lowest scores first.
3fill in blank
hard

Fix the error in the code to get the top 3 scores with their members from 'game_scores'.

Redis
ZREVRANGE game_scores 0 [1] WITHSCORES
Drag options to blanks, or click blank then click option'
A-1
B2
C-3
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 returns 4 elements.
Using negative indexes may cause unexpected results.
4fill in blank
hard

Fill both blanks to get the top 4 scores with their members in descending order from 'game_scores'.

Redis
ZREVRANGE game_scores [1] [2] WITHSCORES
Drag options to blanks, or click blank then click option'
A0
B3
C4
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 4 as stop index returns 5 elements.
Using -1 as stop returns all elements.
5fill in blank
hard

Fill all three blanks to get the top 3 scores with their members from 'game_scores' using ZREVRANGEBYSCORE for scores between 100 and 200.

Redis
ZREVRANGEBYSCORE game_scores [1] [2] LIMIT 0 [3] WITHSCORES
Drag options to blanks, or click blank then click option'
A100
B200
C3
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping min and max values.
Using wrong limit count.