0
0
Redisquery~20 mins

SUNION, SINTER, SDIFF set operations in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Set Operations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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 SUNION A B?
Redis
SADD A apple banana cherry
SADD B banana date fig
SUNION A B
A["banana"]
B["apple", "banana", "cherry"]
C["apple", "banana", "cherry", "date", "fig"]
D["date", "fig"]
Attempts:
2 left
💡 Hint
SUNION returns all unique members from both sets combined.
query_result
intermediate
2: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 SINTER X Y?
Redis
SADD X red blue green
SADD Y blue yellow green
SINTER X Y
A["blue", "green"]
B["red", "yellow"]
C["red", "blue", "green", "yellow"]
D[]
Attempts:
2 left
💡 Hint
SINTER returns only members present in both sets.
query_result
advanced
2: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 SDIFF M N O?
Redis
SADD M cat dog rabbit
SADD N dog hamster
SADD O rabbit parrot
SDIFF M N O
A["rabbit"]
B["dog", "cat"]
C["hamster", "parrot"]
D["cat"]
Attempts:
2 left
💡 Hint
SDIFF returns members in the first set that are not in any of the other sets.
🧠 Conceptual
advanced
1: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?
ASINTER
BSDIFF
CSUNION
DSMEMBERS
Attempts:
2 left
💡 Hint
Think about which command returns only shared members.
📝 Syntax
expert
1:30remaining
Identify the syntax error in this Redis command usage
Consider the following Redis command:

SDIFFSET myset otherset

What is wrong with this command?
AThe command requires only one key, but two are given.
BThe command name is incorrect; it should be SDIFFSTORE.
CThe command should be SUNIONSET instead of SDIFFSET.
DThe command is correct and will run without errors.
Attempts:
2 left
💡 Hint
Check the exact spelling of Redis commands for set operations.