All New

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Register

Login

All New Register Login

linkjobai

Joined 5 days ago

Recently created
Least recently created
Recently updated
Least recently updated
All gists 1

linkjobai / Time-Based Key-Value Store (LeetCode 981): Binary Search on Timestamps

0 likes
0 forks
1 files
Last active 5 days ago
Interview prep notes
interview

Time-Based Key-Value Store (LeetCode 981): Binary Search on Timestamps

The problem: implement set(key, value, timestamp) and get(key, timestamp), where get returns the value set at the largest timestamp less than or equal to the one requested.

Key observation

Timestamps for each key arrive in increasing order. So every key's history is already a sorted list, and get is a binary search.

import bisect
Newer Older

Powered by Opengist ⋅ Load: 25ms⋅

English
العربية Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 简体中文 繁體中文