0
0
Redisquery~20 mins

ZRANGEBYLEX for lexicographic queries in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Lexicographic Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this ZRANGEBYLEX query?
Given a sorted set myzset with members a, b, c, d, and e, what does the command ZRANGEBYLEX myzset [b [d return?
Redis
ZRANGEBYLEX myzset [b [d
A["b", "c", "d"]
B["c", "d"]
C["a", "b", "c", "d"]
D["b", "c"]
Attempts:
2 left
💡 Hint
Remember that square brackets mean inclusive range in lexicographic queries.
📝 Syntax
intermediate
2:00remaining
Which ZRANGEBYLEX command is syntactically correct?
Choose the syntactically valid ZRANGEBYLEX command to get members lexicographically between 'a' (exclusive) and 'c' (inclusive).
AZRANGEBYLEX myzset [a [c
BZRANGEBYLEX myzset [a (c
CZRANGEBYLEX myzset (a (c
DZRANGEBYLEX myzset (a [c
Attempts:
2 left
💡 Hint
Parentheses mean exclusive, square brackets mean inclusive in ZRANGEBYLEX.
optimization
advanced
2:00remaining
How to optimize a ZRANGEBYLEX query for large sorted sets?
You want to retrieve members lexicographically between 'm' and 'z' from a very large sorted set. Which approach optimizes performance best?
AUse ZRANGEBYLEX with a small range and LIMIT option to paginate results.
BUse ZRANGEBYSCORE instead with scores converted from lexicographic values.
CUse ZRANGEBYLEX with exclusive ranges to reduce returned members.
DUse ZRANGEBYLEX without LIMIT to get all results at once.
Attempts:
2 left
💡 Hint
Fetching large ranges at once can be slow; pagination helps.
🔧 Debug
advanced
2:00remaining
Why does this ZRANGEBYLEX command return an empty list?
Given a sorted set with members 'apple', 'banana', 'cherry', 'date', why does ZRANGEBYLEX myzset (banana (cherry return an empty list?
ABecause the sorted set is empty.
BBecause the command syntax is invalid and causes an error.
CBecause the range excludes both 'banana' and 'cherry', and no members lie strictly between them.
DBecause the range should use square brackets instead of parentheses.
Attempts:
2 left
💡 Hint
Parentheses exclude the boundary members.
🧠 Conceptual
expert
2:00remaining
What is the difference between ZRANGEBYLEX and ZRANGEBYSCORE?
Which statement best describes the difference between ZRANGEBYLEX and ZRANGEBYSCORE commands in Redis sorted sets?
AZRANGEBYLEX queries by numeric score values, ZRANGEBYSCORE queries by lexicographic order.
BZRANGEBYLEX queries members by their lexicographic order ignoring scores, while ZRANGEBYSCORE queries by numeric score values.
CBoth commands query by score but ZRANGEBYLEX is faster.
DZRANGEBYLEX only works on sets with string scores, ZRANGEBYSCORE only on numeric members.
Attempts:
2 left
💡 Hint
Think about what 'lex' and 'score' mean.