Your question is Copy Message on Long Press. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
SlackLite stores chat messages in order. Implement a function that processes a sequence of user actions and returns the copied text after each action while keeping message state consistent.
Each message has a unique integer id and a string text. An action is one of:
"long_press": if the message exists, copy its text and mark only that message as copied"delete": remove the message; if it was the copied message, clear the copied state"edit": update the message text; if it is currently copied, the clipboard should immediately reflect the new textReturn a list of clipboard values after every action. Use null when nothing is copied.
messages as a list of objects with keys id and text; actions as a list of objects with keys type, id, and optional textnulldef process_copy_actions(messages, actions):