ThoughSpot Interview Experience/Question - MTS2,3
Summary
Interviewee was asked to write a C++ program to determine service deployment order based on dependencies, ensuring no cycles and proper batching.
Full Experience
Hi everyone! I recently interviewed with the ThoughtSpot Orion Team and wanted to share a specific question I was asked. The team emphasized that this problem is very representative of their daily work on the orchestration layer. If you’re preparing for a role with them, I highly recommend practicing this one.
The Question:
You are given a root directory called:
/services
Inside this directory, each subdirectory represents a service.
Example:
/services
/Auth
config.txt
/Billing
config.txt
/User
config.txt
/Database
config.txt📄 Config File Format
Each service contains a file config.txt.
The file contains exactly one line in this format:
depends=ServiceA,ServiceB,ServiceC
If there are no dependencies:
depends=
🎯 Requirements
Write a C++ program that:
- Scans all service folders inside
/services. - Parses each
config.txt. - Determines the correct deployment order.
- Ensures:
- A service is deployed only after all services listed in its depends line are deployed.
- Services that have no remaining unmet dependencies can be deployed in parallel.
- Outputs deployment batches.
- Detects cyclic dependencies and prints:
Error: Cycle detected. Deployment not possible.
✅ Example
Folder Structure
Auth → depends=Database Billing → depends=Auth User → depends=Auth Database → depends=
Expected Output
Batch 1: Database Batch 2: Auth Batch 3: Billing User
Interview Questions (1)
Service Deployment Order Based on Dependencies
You are given a root directory called /services. Inside this directory, each subdirectory represents a service. Each service contains a file config.txt, which lists its dependencies in the format:
depends=ServiceA,ServiceB,ServiceC
If there are no dependencies, the file will contain just:
depends=
Your task is to write a C++ program that:
- Scans all service folders inside
/services. - Parses each
config.txt. - Determines the correct deployment order such that a service is deployed only after all its dependencies are deployed.
- Groups services that can be deployed in parallel into batches.
- Detects cyclic dependencies and returns an error message if any cycle exists.
Example Folder Structure:
Auth → depends=Database Billing → depends=Auth User → depends=Auth Database → depends=
Expected Output:
Batch 1: Database Batch 2: Auth Batch 3: Billing User
In case of a cycle, output:
Error: Cycle detected. Deployment not possible.