Interview guides · Didi Labs
Didi Labs Software Engineer Interview Guide
Didi Labs Software Engineer interview guide: reported rounds, questions and how candidates describe the process.
The 60-second brief
A Software Engineer at Didi Labs works at the intersection of massive-scale distributed systems, real-time geospatial data, and cutting-edge machine learning. As the US-based research and development arm of DiDi, the world’s leading mobility platform, Didi Labs tackles some of the most complex engineering challenges in modern technology. Engineers here build and scale the core infrastructure that powers millions of rides, deliveries, and autonomous vehicle operations globally every single day. In this role, your work directly impacts global transportation efficiency, passenger safety, and driver livelihoods. Whether you are optimizing real-time dispatch algorithms, building low-latency routing engines, or designing robust infrastructure to handle petabytes of streaming data, you will solve problems where milliseconds and meters matter.
This guide is scoped to a Software Engineer candidate at Didi Labs.
Focus areas
- Data Structures
- Algorithms
- Coding Interviews (Problem Solving Under Constraints)
The Didi Labs interview process
Didi Labs candidates report 4 rounds over 3-5 weeks. The stages below are what candidates describe, not a published process.
Recruiter Call
An introductory call from a recruiter to assess your background, technical interests, and alignment with open team roles.
What to demonstrate
- An introductory call from a recruiter to assess your background, technical interests, and alignment with open team roles
- Depth in Data Structures
How to prepare
- Be able to walk your CV end to end in two minutes, and say why this company specifically.
- Have your salary expectations, notice period and location constraints ready, and ask for the rest of the loop in writing.
Online Assessment
A coding assessment hosted on platforms like CodeSignal, consisting of multiple medium-to-hard algorithmic challenges.
What to demonstrate
- A coding assessment hosted on platforms like CodeSignal, consisting of multiple medium-to-hard algorithmic challenges
- Depth in Data Structures
How to prepare
- Answer aloud and timed: Given an array of coordinates, find the closest K driver partners to a user's request location.
- Answer aloud and timed: Implement an efficient cache mechanism with a custom eviction policy tailored for high-concurrency read operations.
Technical Phone Screens
One or two technical phone screens with engineering team members focusing on live coding and a deep dive into your resume.
What to demonstrate
- One or two technical phone screens with engineering team members focusing on live coding and a deep dive into your resume
- Depth in Data Structures
How to prepare
- Be able to walk your CV end to end in two minutes, and say why this company specifically.
- Have your salary expectations, notice period and location constraints ready, and ask for the rest of the loop in writing.
Virtual Onsite Loop
An intensive stage consisting of up to six rounds scheduled in a single day, covering advanced coding, system design, and behavioral interviews.
What to demonstrate
- An intensive stage consisting of up to six rounds scheduled in a single day
- Covering advanced coding, system design, and behavioral interviews
How to prepare
- Answer aloud and timed: How would you architect a highly available routing engine that handles dynamic ETA calculations based on traffic updates?
- Answer aloud and timed: Design a rate-limiting service to protect downstream microservices from API abuse during peak hours.
Where candidates lose points
Prioritize code optimization early
When writing code during your interview, do not settle for the first working solution. Verbally walk your interviewer through your initial thoughts, explain why a brute-force approach is sub-optimal, and actively work toward the most efficient time and space complexity.
Master geospatial concepts
Since Didi Labs is a mobility-first company, having a basic understanding of geospatial indexing, routing algorithms, and location-based queries will give you a significant advantage during system design discussions.
Practice time management
The onsite loop is a marathon of up to six rounds in one day. Ensure you manage your energy, make use of the 15-minute breaks, and keep your communication concise to avoid running out of time during coding exercises.
Questions & practice
Implement a function to check if a string is a valid integer. Your solution must handle edge cases such as lea
Medium · Coding & Algorithmic Problem Solving
Implement a function to check if a string is a valid integer. Your solution must handle edge cases such as leading zeros, signs, and invalid characters (e.g., convert "00344" to 344, "-324" to -324, and identify "fds332" as invalid).
Approach
- Restate the input: its shape, its size, and what is guaranteed about it.
- Name the brute-force solution and its complexity before improving on it.
- Choose the data structure from the access pattern, not from familiarity.
- State the target complexity and say which constraint rules the naive version out.
Follow-up
- How does this change if the input no longer fits in memory?
- What is the worst case, and how likely is it on real data?
Find the shortest path in a dynamic grid with real-time obstacles, simulating vehicle routing.
Medium · Coding & Algorithmic Problem Solving
Approach
- Restate the input: its shape, its size, and what is guaranteed about it.
- Name the brute-force solution and its complexity before improving on it.
- Choose the data structure from the access pattern, not from familiarity.
- State the target complexity and say which constraint rules the naive version out.
Follow-up
- How does this change if the input no longer fits in memory?
- What is the worst case, and how likely is it on real data?
Given an array of coordinates, find the closest K driver partners to a user's request location.
Medium · Coding & Algorithmic Problem Solving
Approach
- Restate the input: its shape, its size, and what is guaranteed about it.
- Name the brute-force solution and its complexity before improving on it.
- Choose the data structure from the access pattern, not from familiarity.
- State the target complexity and say which constraint rules the naive version out.
Follow-up
- How does this change if the input no longer fits in memory?
- What is the worst case, and how likely is it on real data?
Implement an efficient cache mechanism with a custom eviction policy tailored for high-concurrency read operat
Medium · Coding & Algorithmic Problem Solving
Implement an efficient cache mechanism with a custom eviction policy tailored for high-concurrency read operations.
Approach
- Say what the runtime actually does before reasoning about the code.
- Name what is shared across threads and what owns each piece of state.
- Identify the window where an invariant is briefly untrue.
- Distinguish a value from a reference to it, and say which one you handed out.
Follow-up
- What happens if two callers reach this at the same time?
- Where could this allocate more than you expect?
Denormalise tenant onto revisions and backfill it live
Hard · denormalisation · online migration · backfill
resource_revision (revision_id, resource_id, version, actor_user_id, change_kind, patch, request_id, created_at) has 400M rows and no tenant column; tenant_id lives only on resource. Two reads need it: a tenant-scoped audit feed ordered by created_at DESC, and an offboarding purge. Both join back to resource today. Justify adding tenant_id to resource_revision against those two reads, name the anomaly the copy introduces and the constraint that prevents it, then give the ordered migration for a live table taking 1.2k writes/second — the lock each step takes, how the backfill is batched, and where each step stops being reversible. PostgreSQL 16.
Approach
- Justify from the access path rather than from taste. Without the column, the audit feed either scans resource_revision by created_at and discards other tenants' rows, or resolves the tenant's resource_ids first and probes with them — both proportional to the tenant's whole history rather than to one page. With (tenant_id, created_at DESC, revision_id DESC) it is a seek that stops at 50 rows, and the purge becomes a ranged delete instead of a join.
- Name the cost exactly: a second copy of a fact can disagree with the first. Make the disagreement unwritable rather than documented — add UNIQUE (resource_id, tenant_id) on resource so it can serve as a foreign-key target, then FOREIGN KEY (resource_id, tenant_id) REFERENCES resource (resource_id, tenant_id) on the revision table. A revision can then only ever carry its parent's tenant.
- Step one, expand: ALTER TABLE resource_revision ADD COLUMN tenant_id BIGINT NULL, with no default, so it is a catalogue change and no rewrite. It still needs ACCESS EXCLUSIVE for an instant, and that instant queues behind the longest open transaction on the table while every later query queues behind it — set lock_timeout to 2s and retry rather than wait.
- Step two, dual-write: deploy the writer that populates tenant_id on every new revision while reads still use the join. Reversible by redeploying the previous build, because nothing reads the column yet.
Follow-up
- The backfill is half finished and a rollback is required. What state is the table in, and what does the previous build do with a half-populated column?
- How do you verify the backfill actually finished, given rows are still being inserted while it runs?
Replace offset paging on the resource feed with keyset
Easy · keyset pagination · composite index · sort order
resource holds resource_id, tenant_id, owner_user_id, title, body_ref, version, status ('draft','active','archived','deleted'), created_at, updated_at, deleted_at, with an index on (tenant_id, status, updated_at DESC, resource_id DESC). The listing endpoint returns active resources for one tenant, newest update first, 50 per page, today with LIMIT 50 OFFSET n. Tenants reach page 400 and rows are created while they read. Write the keyset query, define what the cursor carries and how it is encoded, and say which part of the index each predicate uses. Assume PostgreSQL 16.
Approach
- Name the two failures separately. OFFSET 20000 makes the server produce and discard 20,000 rows, so page cost grows with depth rather than with page size. Independently, any write that changes how many rows sort above the offset moves the window between two fetches, and the direction decides which anomaly you get: an insert lands at the head of updated_at DESC and pushes already-returned rows down past the boundary, so they are returned a second time; a delete above the offset, or a row whose updated_at is bumped above the cursor, pulls rows up and one is never returned at all. Nothing in the response reveals either.
- Write the seek: WHERE tenant_id = $1 AND status = 'active' AND (updated_at, resource_id) < ($2, $3) ORDER BY updated_at DESC, resource_id DESC LIMIT 50. The row-value comparison is one index range rather than a disjunction, and both columns are NOT NULL, which is what makes that comparison well defined.
- Map each predicate onto the index: tenant_id and status are equality on the leading columns, (updated_at, resource_id) is the range, and the ORDER BY matches the index order so no Sort node appears and the scan stops after 50 rows. The DESC in the definition only matters for mixed directions — a plain ascending btree on the same columns is read backwards for this query.
- Put both sort columns in the cursor and nothing the client can tamper with into another tenant: base64 of (updated_at, resource_id), validated server-side, with tenant_id taken from the principal.
Follow-up
- The client asks for 'jump to page 400'. What do you offer instead, and what does the honest version cost?
- Sort order becomes user-selectable across four columns. How many indexes is that, and which would you refuse to add?
Design a real-time ride-matching (dispatch) system that pairs drivers with passengers under low-latency constr
Medium · System Design & Architecture
Design a real-time ride-matching (dispatch) system that pairs drivers with passengers under low-latency constraints.
Approach
- Fix the scope first: who calls this, how often, and what they do when it fails.
- Name the read and write paths separately; they rarely have the same bottleneck.
- Choose a partition key and say what query it makes expensive.
- State the consistency you need, and where you are willing to be stale.
Follow-up
- What breaks first when traffic grows ten times?
- How does this behave when that dependency is down for an hour?
Design a geospatial tracking service that can ingest and store real-time GPS coordinates from millions of acti
Medium · System Design & Architecture
Design a geospatial tracking service that can ingest and store real-time GPS coordinates from millions of active drivers simultaneously.
Approach
- Fix the scope first: who calls this, how often, and what they do when it fails.
- Name the read and write paths separately; they rarely have the same bottleneck.
- Choose a partition key and say what query it makes expensive.
- State the consistency you need, and where you are willing to be stale.
Follow-up
- What breaks first when traffic grows ten times?
- How does this behave when that dependency is down for an hour?
How would you architect a highly available routing engine that handles dynamic ETA calculations based on traff
Medium · System Design & Architecture
How would you architect a highly available routing engine that handles dynamic ETA calculations based on traffic updates?
Approach
- Fix the scope first: who calls this, how often, and what they do when it fails.
- Name the read and write paths separately; they rarely have the same bottleneck.
- Choose a partition key and say what query it makes expensive.
- State the consistency you need, and where you are willing to be stale.
Follow-up
- What breaks first when traffic grows ten times?
- How does this behave when that dependency is down for an hour?
Design a rate-limiting service to protect downstream microservices from API abuse during peak hours.
Medium · System Design & Architecture
Approach
- Fix the scope first: who calls this, how often, and what they do when it fails.
- Name the read and write paths separately; they rarely have the same bottleneck.
- Choose a partition key and say what query it makes expensive.
- State the consistency you need, and where you are willing to be stale.
Follow-up
- What breaks first when traffic grows ten times?
- How does this behave when that dependency is down for an hour?
Walk me through the architecture of the most complex system you have designed and deployed to production.
Medium · Project Deep-Dive & Experience
Approach
- Fix the scope first: who calls this, how often, and what they do when it fails.
- Name the read and write paths separately; they rarely have the same bottleneck.
- Choose a partition key and say what query it makes expensive.
- State the consistency you need, and where you are willing to be stale.
Follow-up
- What breaks first when traffic grows ten times?
- How does this behave when that dependency is down for an hour?
Describe a situation where you had to make a difficult trade-off between system latency and data consistency.
Medium · Project Deep-Dive & Experience
Approach
- Clarify what is being asked and what a complete answer contains.
- State your assumptions explicitly before working the problem.
- Say what you would check first and why it is the highest-information step.
- Work from the requirement backwards to the design.
Follow-up
- What assumption would you test first?
- How would you know your answer was wrong?
Explain a major technical bottleneck you encountered in a past project, how you diagnosed it, and how you reso
Medium · Project Deep-Dive & Experience
Explain a major technical bottleneck you encountered in a past project, how you diagnosed it, and how you resolved it.
Approach
- Clarify what is being asked and what a complete answer contains.
- State your assumptions explicitly before working the problem.
- Say what you would check first and why it is the highest-information step.
- Work from the requirement backwards to the design.
Follow-up
- What assumption would you test first?
- How would you know your answer was wrong?
Choose a project from your resume and explain what you would do differently if you had to rebuild it from scra
Medium · Project Deep-Dive & Experience
Choose a project from your resume and explain what you would do differently if you had to rebuild it from scratch today.
Approach
- Clarify what is being asked and what a complete answer contains.
- State your assumptions explicitly before working the problem.
- Say what you would check first and why it is the highest-information step.
- Work from the requirement backwards to the design.
Follow-up
- What assumption would you test first?
- How would you know your answer was wrong?
Every query on one table stalls for forty seconds mid-deploy
Medium · lock contention · ddl · migrations
During a release on PostgreSQL, every query touching resource times out for about 40 seconds and then recovers with no intervention. The release ran one migration, ALTER TABLE resource ADD COLUMN archived_reason TEXT, and the migration log shows it completing in 6 ms. Unrelated tables showed no change in error rate. Explain how a 6 ms statement caused a 40-second stall, give the ordered checks you would run on a live system to confirm it, and give the migration procedure that prevents a repeat.
Approach
- Separate the statement's duration from the lock's duration. ADD COLUMN with no default is a catalogue-only change and genuinely runs in milliseconds, but it requires ACCESS EXCLUSIVE, and it cannot acquire that until every transaction already touching the table has finished.
- Account for the queueing, which is the part that surprises people. A lock request that is waiting blocks later requests for conflicting modes behind it rather than letting them overtake, so one long-open transaction holds the DDL and the DDL holds all the traffic. The stall length is set by the longest open transaction, not by the size of the change.
- Confirm on a live system in this order: pg_stat_activity for that table ordered by xact_start, looking for the oldest transaction and specifically for state = idle in transaction; then pg_locks where granted = false to find the waiter; then join them on pid to name blocker and blocked. pg_blocking_pids() does that join for you and is the fastest single call.
- Prevent rather than merely time it better. Set lock_timeout to a second or two on the migration session so the DDL abandons the queue after a bounded wait and is retried, instead of holding it for as long as the oldest transaction lives. Be exact about what that buys: queries arriving during the wait still queue behind the pending ACCESS EXCLUSIVE request, so each attempt costs them up to one lock_timeout of added latency. The outage goes from 40 seconds to about one second per attempt, not to zero. Also run migrations away from deploy-time peaks, and put a statement timeout and an idle-in-transaction timeout on the analytics role that opens the long transactions.
Follow-up
- The same release also wants NOT NULL on that column. What is the sequence that gets there without a long lock?
- Your lock_timeout retry fails ten times in a row because the analytics transaction is always open. What do you change?
Suggested practice checklist
Built from the rounds and topics Didi Labs candidates report.
Day 1 — Map the Didi Labs loop
- Write out the reported sequence: Recruiter Call, Online Assessment, Technical Phone Screens, Virtual Onsite Loop.
- For each round, write one sentence on what it is judging, from the description above, and mark the one you are least ready for.
Deliverable: A one-page map of the 4 reported rounds, with the weakest marked.
Day 2 — Work Data Structures
- Spend the session on Data Structures, which Didi Labs candidates report being tested on.
- Write one worked example in Data Structures and time yourself on it.
Deliverable: One timed worked example in Data Structures.
Day 3 — Work Algorithms
- Spend the session on Algorithms, which Didi Labs candidates report being tested on.
- Write one worked example in Algorithms and time yourself on it.
Deliverable: One timed worked example in Algorithms.
Day 4 — Work Coding Interviews (Problem Solving Under Constraints)
- Spend the session on Coding Interviews (Problem Solving Under Constraints), which Didi Labs candidates report being tested on.
- Write one worked example in Coding Interviews (Problem Solving Under Constraints) and time yourself on it.
Deliverable: One timed worked example in Coding Interviews (Problem Solving Under Constraints).
Day 5 — Answer out loud: Coding & Algorithmic Problem Solving
- Answer aloud, timed: Implement a function to check if a string is a valid integer. Your solution must handle edge cases such as leading zeros, signs, and invalid characters (e.g., convert
"00344"to344,"-324"to-324, and identify"fds332"as invalid). - Answer aloud, timed: Find the shortest path in a dynamic grid with real-time obstacles, simulating vehicle routing.
Deliverable: Spoken answers to 2 reported Coding & Algorithmic Problem Solving question(s), under time.
Day 6 — Answer out loud: System Design & Architecture
- Answer aloud, timed: Design a real-time ride-matching (dispatch) system that pairs drivers with passengers under low-latency constraints.
- Answer aloud, timed: Design a geospatial tracking service that can ingest and store real-time GPS coordinates from millions of active drivers simultaneously.
Deliverable: Spoken answers to 2 reported System Design & Architecture question(s), under time.
Day 7 — Answer out loud: Project Deep-Dive & Experience
- Answer aloud, timed: Walk me through the architecture of the most complex system you have designed and deployed to production.
- Answer aloud, timed: Describe a situation where you had to make a difficult trade-off between system latency and data consistency.
Deliverable: Spoken answers to 2 reported Project Deep-Dive & Experience question(s), under time.
Behavioural preparation
Behavioural rounds judge the decision you made and what it cost.
Reverse your own decision and price the reversal
Medium · reversibility · measurement · migrations
Describe a technical decision you made and later reversed. Pick one that cost something: a service you split and merged back, a cache you added and removed, an index you created that pushed the planner onto a worse plan, a projection you rebuilt from scratch. State what you believed when you decided, the measurement that changed your mind, how long the wrong version ran in production, and what the reversal cost in migrations, dual writes, and a deprecation window for callers you did not own.
Approach
- State the original rationale without irony, in the version you would still defend given what was known then. If it is not defensible, the story is about carelessness rather than judgement, and a different example serves you better.
- Give the measurement that moved with a before and after: the p99 that did not improve, the cache hit rate that sat at 40%, the plan that flipped to a sequential scan once the table passed a size you can name.
- Cost the reversal in steps, not adjectives: expand-and-contract deploys, the dual-write window, the callers who had to be notified, the rows already written in the wrong shape that had to be backfilled or abandoned.
- Distinguish reversal from rewrite by naming what you kept. Most good reversals preserve the schema or the interface and undo one decision inside it, which is also why they were affordable.
Follow-up
- What in that decision was irreversible, and did you know it was irreversible when you made it?
- How did you tell the people who had already built on top of the original decision?
Turn a code review disagreement into a decision
Easy · code review · optimistic concurrency · communication
A colleague's change updates a row with UPDATE resource SET version = version + 1 WHERE resource_id = $1 AND version = $2 and treats an affected-row count of zero as a successful no-op. You read that as a silently lost update; they think returning 200 is friendlier to clients than returning a conflict. Describe how you have handled a review disagreement of this shape: what goes in the comment, when you leave the thread, and who decides. Then write the comment you would leave here, in under 80 words.
Approach
- Sort the disagreement before writing anything. A silently discarded write is a correctness claim about data; the choice between 409 and 412 is taste. Only the first justifies blocking a merge, and saying which one you are doing is most of the value of the comment.
- Make the claim reproducible in the comment itself with an interleaving rather than a principle: A reads version 7, B reads version 7, B commits version 8, A's predicate matches zero rows, A is told it succeeded and A's edit is gone.
- Offer the alternative with its cost attached: return 409 carrying the current version and the revision that won, so the client can re-read and re-apply. Note that automatic retry is not the fix, because a retry re-reads the winner's state and reapplies an intent formed against data that no longer exists.
- Apply an escalation rule you can state: two round trips on the thread, then a call, and the service's owner decides rather than the reviewer. A reviewer who cannot be overruled is a bottleneck with extra steps.
Follow-up
- Where would you put the test that fails if someone reintroduces the swallowed zero rowcount?
- The author says clients cannot handle a 409. How do you check whether that is true?
Tell callers you do not own that their integration breaks
Medium · deprecation · compatibility · stakeholders
A field in a write endpoint's response must change shape. You own the endpoint; you do not own the four internal callers or the outbound webhook consumers who read it. Describe a deprecation you were responsible for: what you shipped first, how you established who was actually reading the field, the window you gave and what set its length, what you did about the consumer who never moved, and how you decided removal was safe. Name the signal you used, not the announcement you sent.
Approach
- Establish the reader set empirically rather than from a wiki of owners: per-field usage counters keyed by principal, or access logs attributed to a consumer. State the blind spot of whichever you pick, since a consumer that reads the field only on a monthly job will not appear in a week of logs.
- Ship additive first. Populate the new field alongside the old one so no reader is forced to move, which is also what keeps a rolling deploy safe, because old and new instances answer the same requests at the same time and a rollback must still find the old shape present.
- Set the window from the slowest legitimate consumer's release cadence, not from your calendar, and decide separately what to do for a consumer with no release process at all, such as an external webhook endpoint you can only email.
- Convert silence into evidence before you rely on it: a short, low-traffic removal window that makes a still-dependent consumer fail visibly and loudly while you are watching, rather than at three in the morning after you have moved on.
Follow-up
- How would you detect a consumer that reads the field only during a monthly export?
- One caller refuses to move and has a commercial relationship behind it. What changes in your plan and what does not?