0
0
Redisquery~20 mins

ZRANGEBYSCORE for score-based queries in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ZRANGEBYSCORE Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Output of ZRANGEBYSCORE with inclusive range
Given a sorted set 'players' with scores: {"Alice": 50, "Bob": 70, "Charlie": 70, "Diana": 90}, what is the output of the command ZRANGEBYSCORE players 50 70?
A["Alice", "Bob", "Charlie"]
B["Alice", "Diana"]
C["Bob", "Charlie"]
D["Alice", "Bob"]
Attempts:
2 left
💡 Hint
ZRANGEBYSCORE includes elements with scores equal to the min and max by default.
query_result
intermediate
2:00remaining
ZRANGEBYSCORE with exclusive min and max
What is the result of ZRANGEBYSCORE players (50 (90 on the same sorted set as before?
A["Bob", "Charlie"]
B["Alice", "Bob", "Charlie"]
C["Diana"]
D[]
Attempts:
2 left
💡 Hint
Parentheses before a score mean exclusive range boundary.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in ZRANGEBYSCORE usage
Which option contains a syntax error when trying to get elements with scores between 10 and 20?
AZRANGEBYSCORE myset 10 (20
BZRANGEBYSCORE myset (10 20
CZRANGEBYSCORE myset 10 20 (LIMIT 0 5)
DZRANGEBYSCORE myset 10 20
Attempts:
2 left
💡 Hint
Check the syntax for LIMIT usage in ZRANGEBYSCORE.
optimization
advanced
2:00remaining
Optimizing ZRANGEBYSCORE for large sorted sets
You want to retrieve only the first 3 elements with scores between 100 and 200 from a large sorted set. Which command is the most efficient?
AZRANGEBYSCORE myset (100 (200 LIMIT 0 3
BZRANGEBYSCORE myset 100 200 LIMIT 0 3
CZRANGEBYSCORE myset 100 200
DZRANGEBYSCORE myset 100 200 LIMIT 3 0
Attempts:
2 left
💡 Hint
LIMIT offset count syntax helps reduce data transferred.
🧠 Conceptual
expert
2:00remaining
Understanding ZRANGEBYSCORE with negative and positive infinity
What is the output of ZRANGEBYSCORE myset -inf +inf on a sorted set with elements {"a": 1, "b": 2, "c": 3}?
A["a"]
B[]
C["c", "b", "a"]
D["a", "b", "c"]
Attempts:
2 left
💡 Hint
Negative and positive infinity include all scores.