Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Authentication Manager Design
00:00
5 left

Authentication Manager Design

HardSQL · PostgreSQL

Problem

Design Authentication Manager (LeetCode 1797) with a constraint of 10^5 queries.

Asked in the Coding round stage. For this SQL version, process the ordered authentication operations and return the number of unexpired tokens whenever a count operation occurs. A token is valid only when its expiration time is strictly greater than the operation time. Generating an existing token replaces its expiration time, while renewing an expired or unknown token has no effect.

Output

  1. One row per count operation with query_id, event_time, and active_token_count.
  2. Include only count operations.
  3. Order by query_id ascending.

Schema

auth_manager_config
ColumnTypeDescription
manager_idPKINTAuthentication manager identifier
time_to_liveINTToken lifetime in time units
auth_queries
ColumnTypeDescription
query_idPKINTSequence identifier for an authentication operation
manager_idINTAuthentication manager used by the operation
operationVARCHAR(20)Operation name: generate, renew, or count
token_idVARCHAR(100)Token affected by generate or renew
event_timeINTTime at which the operation occurs
Tablesauth_manager_configauth_queries
Interviewer

Your question is Authentication Manager Design. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.