Challenge - 5 Problems
Redis List Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the resulting list after LPUSH?
You start with an empty Redis list named 'fruits'. You run the command:
What is the order of elements in the list 'fruits' after this command?
LPUSH fruits apple banana cherryWhat is the order of elements in the list 'fruits' after this command?
Redis
LPUSH fruits apple banana cherry
Attempts:
2 left
💡 Hint
LPUSH inserts elements to the start of the list, from left to right.
✗ Incorrect
LPUSH adds elements to the head of the list in the order they are given, so the last element ends up at the head.
❓ query_result
intermediate2:00remaining
What is the resulting list after RPUSH?
You have an empty Redis list named 'colors'. You run the command:
What is the order of elements in the list 'colors' after this command?
RPUSH colors red green blueWhat is the order of elements in the list 'colors' after this command?
Redis
RPUSH colors red green blue
Attempts:
2 left
💡 Hint
RPUSH adds elements to the end of the list in the order they appear.
✗ Incorrect
RPUSH appends elements to the tail of the list in the order given, so the list keeps the same order as the arguments.
📝 Syntax
advanced2:00remaining
Which LPUSH command is syntactically correct?
Which of the following LPUSH commands will run without syntax errors in Redis?
Attempts:
2 left
💡 Hint
Redis commands take arguments separated by spaces, no brackets or commas.
✗ Incorrect
Only option A uses the correct Redis command syntax with space-separated arguments and optional quotes for strings.
❓ query_result
advanced2:00remaining
What is the list after mixed LPUSH and RPUSH?
You start with an empty Redis list named 'numbers'. You run these commands in order:
1. RPUSH numbers 1 2 3
2. LPUSH numbers 0
3. RPUSH numbers 4
What is the final order of elements in the list 'numbers'?
1. RPUSH numbers 1 2 3
2. LPUSH numbers 0
3. RPUSH numbers 4
What is the final order of elements in the list 'numbers'?
Redis
RPUSH numbers 1 2 3 LPUSH numbers 0 RPUSH numbers 4
Attempts:
2 left
💡 Hint
LPUSH adds to the front, RPUSH adds to the end.
✗ Incorrect
RPUSH adds 1,2,3 to the end, LPUSH adds 0 to the front, then RPUSH adds 4 to the end, resulting in [0,1,2,3,4].
🧠 Conceptual
expert2:00remaining
Why choose LPUSH over RPUSH in Redis list insertion?
Which reason best explains when LPUSH is preferred over RPUSH for inserting elements into a Redis list?
Attempts:
2 left
💡 Hint
LPUSH adds elements at the head, useful for last-in-first-out order.
✗ Incorrect
LPUSH inserts at the front, making it ideal for stack-like behavior where the last added element is first to be removed.