Challenge - 5 Problems
Set Operations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the result of SUNION on two sets?
Given two Redis sets:
Set A contains: {"apple", "banana", "cherry"}
Set B contains: {"banana", "date", "fig"}
What is the result of
Set A contains: {"apple", "banana", "cherry"}
Set B contains: {"banana", "date", "fig"}
What is the result of
SUNION A B?Redis
SADD A apple banana cherry SADD B banana date fig SUNION A B
Attempts:
2 left
💡 Hint
SUNION returns all unique members from both sets combined.
✗ Incorrect
SUNION combines all unique elements from both sets. Since 'banana' is in both, it appears once. The result includes all unique fruits from both sets.
❓ query_result
intermediate2:00remaining
What does SINTER return for overlapping sets?
Given two Redis sets:
Set X contains: {"red", "blue", "green"}
Set Y contains: {"blue", "yellow", "green"}
What is the output of
Set X contains: {"red", "blue", "green"}
Set Y contains: {"blue", "yellow", "green"}
What is the output of
SINTER X Y?Redis
SADD X red blue green SADD Y blue yellow green SINTER X Y
Attempts:
2 left
💡 Hint
SINTER returns only members present in both sets.
✗ Incorrect
SINTER returns the intersection of the sets, which are the elements present in both X and Y: blue and green.
❓ query_result
advanced2:00remaining
What is the output of SDIFF with three sets?
Given three Redis sets:
Set M contains: {"cat", "dog", "rabbit"}
Set N contains: {"dog", "hamster"}
Set O contains: {"rabbit", "parrot"}
What is the result of
Set M contains: {"cat", "dog", "rabbit"}
Set N contains: {"dog", "hamster"}
Set O contains: {"rabbit", "parrot"}
What is the result of
SDIFF M N O?Redis
SADD M cat dog rabbit
SADD N dog hamster
SADD O rabbit parrot
SDIFF M N OAttempts:
2 left
💡 Hint
SDIFF returns members in the first set that are not in any of the other sets.
✗ Incorrect
SDIFF returns elements in M that are not in N or O. 'cat' is only in M, so it is returned.
🧠 Conceptual
advanced1:30remaining
Which Redis command would you use to find common elements between sets?
You want to find elements that exist in all given Redis sets. Which command should you use?
Attempts:
2 left
💡 Hint
Think about which command returns only shared members.
✗ Incorrect
SINTER returns the intersection of sets, i.e., elements common to all sets.
📝 Syntax
expert1:30remaining
Identify the syntax error in this Redis command usage
Consider the following Redis command:
What is wrong with this command?
SDIFFSET myset othersetWhat is wrong with this command?
Attempts:
2 left
💡 Hint
Check the exact spelling of Redis commands for set operations.
✗ Incorrect
The correct command to store the difference of sets is SDIFFSTORE, not SDIFFSET.