Challenge - 5 Problems
ZRANGEBYSCORE Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2: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?Attempts:
2 left
💡 Hint
ZRANGEBYSCORE includes elements with scores equal to the min and max by default.
✗ Incorrect
ZRANGEBYSCORE returns all elements with scores between the min and max inclusive. Here, Alice (50), Bob (70), and Charlie (70) are included.
❓ query_result
intermediate2:00remaining
ZRANGEBYSCORE with exclusive min and max
What is the result of
ZRANGEBYSCORE players (50 (90 on the same sorted set as before?Attempts:
2 left
💡 Hint
Parentheses before a score mean exclusive range boundary.
✗ Incorrect
The command excludes scores equal to 50 and 90, so only Bob and Charlie with score 70 are returned.
📝 Syntax
advanced2: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?
Attempts:
2 left
💡 Hint
Check the syntax for LIMIT usage in ZRANGEBYSCORE.
✗ Incorrect
The LIMIT option requires the keyword LIMIT before offset and count, not parentheses around it.
❓ optimization
advanced2: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?
Attempts:
2 left
💡 Hint
LIMIT offset count syntax helps reduce data transferred.
✗ Incorrect
Using LIMIT 0 3 returns only the first 3 matching elements, reducing memory and network usage.
🧠 Conceptual
expert2: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}?Attempts:
2 left
💡 Hint
Negative and positive infinity include all scores.
✗ Incorrect
Using -inf and +inf as min and max returns all elements in ascending score order.