Level 1 Notes with IDs and timestamps
Build the in-memory core of a personal note-taking app, SecondBrainSystem. Every call that changes something is given the current time as an integer timestamp; timestamps never go down from one call to the next (equal is allowed).
Implement:
SecondBrainSystem(): an empty system.create_note(timestamp, title, content) -> str: store a new note and return its id. Ids are"note_1","note_2", … in creation order, and are never reused, even after a delete. The note'screated_atandupdated_atare bothtimestamp.get_note(note_id) -> dict | None: the note as{"id": ..., "title": ..., "content": ..., "created_at": ..., "updated_at": ...}, orNoneif there is no such note. Return a fresh dict: changing it must not change the stored note.update_note(timestamp, note_id, title=None, content=None) -> bool: replace the title and/or content (aNoneargument leaves that field alone) and setupdated_at = timestamp. ReturnFalse, changing nothing, if the note doesn't exist.delete_note(note_id) -> bool: remove the note;Falseif it doesn't exist.
sb = SecondBrainSystem()
sb.create_note(10, "Groceries", "eggs, milk") # "note_1"
sb.create_note(12, "Ideas", "") # "note_2"
sb.update_note(15, "note_1", content="eggs") # True
sb.get_note("note_1")
# {"id": "note_1", "title": "Groceries", "content": "eggs", "created_at": 10, "updated_at": 15}
sb.delete_note("note_2") # True
sb.create_note(20, "Ideas v2", "...") # "note_3" (note_2 is not reused)
sb.update_note(21, "note_2", title="x") # False
Titles and contents are arbitrary strings (possibly empty).