0
0
HLDsystem_design~10 mins

Message queue concept in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a message queue that stores messages in a FIFO order.

HLD
message_queue = [1]()
Drag options to blanks, or click blank then click option'
AStack
BQueue
CList
DSet
Attempts:
3 left
💡 Hint
Common Mistakes
Using a Stack instead of a Queue causes last-in-first-out behavior.
Using a Set loses message order.
2fill in blank
medium

Complete the code to add a message to the queue.

HLD
message_queue.[1](message)
Drag options to blanks, or click blank then click option'
Aenqueue
Bpop
Cput
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using pop removes messages instead of adding.
Using enqueue is not a standard method name in Python's queue.
3fill in blank
hard

Fix the error in the code to retrieve a message from the queue without removing it.

HLD
next_message = message_queue.[1]()
Drag options to blanks, or click blank then click option'
Apeek
Bget
Cpop
Dfront
Attempts:
3 left
💡 Hint
Common Mistakes
Using get removes the message from the queue.
Using pop removes the message and is not a standard queue method.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps message IDs to their content for messages longer than 5 characters.

HLD
{msg.id: msg.[1] for msg in messages if len(msg.[2]) > 5}
Drag options to blanks, or click blank then click option'
Acontent
Bid
Ctext
Dbody
Attempts:
3 left
💡 Hint
Common Mistakes
Using the message ID as the value instead of the content.
Checking length on the ID instead of the message text.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of messages where the content length is greater than 10 and keys are uppercase IDs.

HLD
{msg.[1].upper(): msg.[2] for msg in messages if len(msg.[3]) > 10}
Drag options to blanks, or click blank then click option'
Aid
Bcontent
Cbody
Dupper
Attempts:
3 left
💡 Hint
Common Mistakes
Using content as the key instead of the value.
Checking length on the content instead of the body.