Topfolio
Career TracksFree CoursesPracticeWork ExperienceProjects
For Employers
Start Free
Topfolio

Learn data analytics online. Real skills, real projects, real community.

courses

  • Career Tracks
  • Work Experience
  • Best Data Analyst Course in India
  • SQL Fundamentals
  • SQL Advanced
  • Python for Data
  • Micro Free Courses

practice

  • SQL Fundamentals Interview Test
  • SQL Advanced Coding Test
  • All Practice Tests

resources

  • How to Become a Data Analyst
  • SQL Interview Questions
  • Data Analyst Salary Guide
  • Free Datasets for Practice
  • SQL vs NoSQL Guide
  • Data Analyst vs Data Engineer vs Data Scientist

employers

  • Enterprise Screening
  • AI Proctoring Demo
  • Volume Pricing
  • Employer Portal

company

  • About
  • Terms
© 2026 Topfolio. All rights reserved.Made with ❤️ for aspiring analysts
Topfolio
Career TracksFree CoursesPracticeWork ExperienceProjects
For Employers
Start Free

Generate Collision-Safe Short Codes

easy~10 min10 pts
📊 View Insights

Problem

# Generate Collision-Safe Short Codes A URL shortener maps a random code to a long URL. Codes must be unpredictable (`secrets`, not `random`) and unique against existing codes. ### Task Implement `mint_code(existing: set[str], length: int = 7) -> str` that returns a `[A-Za-z0-9]` code of `length` chars not present in `existing`, retrying on collision (give up after 1000 tries and raise `ValueError`). ### Example `mint_code({"abc1234"})` → a 7-char code not equal to `"abc1234"`; `mint_code(set(), length=4)` → any 4-char code.
fastapiurl-shortenersecrets
📊
📊 View Question Telemetry & Insights
Failure rate, silent bug autopsy & optimal query construction
Inspect →

Master SQL & Data Analytics

Ready to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.

Explore the 12-Week Data Analyst Career Track

Related questions

  • Implement FastAPI Lifespan Model Cachingmedium
  • Verify a Webhook HMAC Signaturemedium
  • Paginate with an Opaque Cursormedium
  • Enforce Model Schema Signatures with MLflowmedium
  • Compute Population Stability Index (PSI) with Epsilon Smoothingmedium
  • Deterministic Salted Hash Routing for A/B Canarieseasy
  • Two-Sample Kolmogorov-Smirnov Drift Test Runnereasy
  • Longest Substring with At Most K Distinct Charactersmedium
SQL Editor

Run your code to see the result here.

Topfolio

Learn data analytics online. Real skills, real projects, real community.

courses

  • Career Tracks
  • Work Experience
  • Best Data Analyst Course in India
  • SQL Fundamentals
  • SQL Advanced
  • Python for Data
  • Micro Free Courses

practice

  • SQL Fundamentals Interview Test
  • SQL Advanced Coding Test
  • All Practice Tests

resources

  • How to Become a Data Analyst
  • SQL Interview Questions
  • Data Analyst Salary Guide
  • Free Datasets for Practice
  • SQL vs NoSQL Guide
  • Data Analyst vs Data Engineer vs Data Scientist

employers

  • Enterprise Screening
  • AI Proctoring Demo
  • Volume Pricing
  • Employer Portal

company

  • About
  • Terms
© 2026 Topfolio. All rights reserved.Made with ❤️ for aspiring analysts