Object versioning preserves earlier writes and represents deletion with a new delete marker rather than destroying history.
Design a VersionedObjectStore:
put(key, value) creates a version and returns its globally increasing ID, starting at 1.deleteObject(key) creates a delete-marker version and returns its ID, even when the key is absent.get(key) returns the latest value or "NOT_FOUND" when absent or hidden by a marker.getVersion(key, versionId) returns that historical value only when the version belongs to key and is not a marker.restore(key, versionId) copies a valid historical value into a new version and returns the new ID; otherwise it returns -1.
Values never equal "NOT_FOUND".
Example 1:
Example 2:
Constraints
- Keys and values contain
1 to 100 printable ASCII characters. - Values are not
"NOT_FOUND". - At most
10^4 operations are performed.