Thread Count (Also for Infra Automation Intern)

Problem Overview

  • Assign each micro-service a max thread count so adjacent services differ by exactly 1, honor known nodes, and minimize the total threads over the tree.
  • Input: service_nodes, tree edges service_from/service_to, and k pairs currentValues [index, threads]. Output: array of per-node max threads.
  • Constraints: 1 ≤ service_nodes ≤ 1e6; 1-based indices; thread values ≤ 1e6; solution always exists.
  • Real-world: thread limits in micro-services; Snowflake coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: