Skip to content

Instantly share code, notes, and snippets.

@duncangh
Created July 8, 2019 00:42
Show Gist options
  • Save duncangh/6f1a9428591ff4071b651e83957a2749 to your computer and use it in GitHub Desktop.
Save duncangh/6f1a9428591ff4071b651e83957a2749 to your computer and use it in GitHub Desktop.
Data Structures Python deque

Recent Emojis

if the implementation is recent emojis, then we could use a deque. The deque will be instantiated with a max length of 30 which is consistent with what Apple uses.

from collections import deque

recent_emojis = deque([], maxlen=30)

def update_recent_emojis(emoji_used, recent_emojis : deque):
    if emoji_used in recent_emojis:
        recent_emojis.remove(emoji_used)

    recent_emojis.appendleft(emoji_used)
    return recent_emojis
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment