FastPrepThread Count (Also for Infra Automation Intern)
Problems/Thread Count (Also for Infra Automation Intern)

Thread Count (Also for Infra Automation Intern)

Snowflake logoSnowflake● HardINTERNOA

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

There are service_nodes microservices connected by bidirectional edges that form a tree. Edge j connects service_from[j] and service_to[j].

Each microservice has a maximum live-thread value. The values of any two adjacent microservices must differ by exactly 1. Some values were lost, and only k values remain known. Each row [i, value] in currentValues fixes the value of microservice i.

Find the live-thread value for every microservice such that all fixed values and adjacency requirements hold and the total sum of values is as small as possible. A valid solution is guaranteed to exist.

Returns: int[] of length service_nodes, where element i is the live-thread value of microservice i + 1.

Function

findMaximumNumberLiveThreads(service_nodes: int, service_from: int[], service_to: int[], k: int, currentValues: int[][]) → int[]

Examples

Example 1

service_nodes = 4service_from = [1, 2, 2]service_to = [2, 3, 4]k = 3currentValues = [[1, 3], [2, 4], [3, 3]]return = [3, 4, 3, 3]

There are four microservices and three edges: (1, 2), (2, 3), and (2, 4).

The known values fix nodes 1, 2, and 3 to 3, 4, and 3. Assigning node 4 the value 3 satisfies the required difference of exactly 1 across every edge and minimizes the total. The result is [3, 4, 3, 3].

Constraints

  • 1 ≤ service_nodes ≤ 10^5
  • 1 ≤ service_from[i], service_to[i] ≤ service_nodes
  • 1 ≤ k ≤ service_nodes
  • 1 ≤ currentValues[i][0] ≤ service_nodes
  • 1 ≤ currentValues[i][1] ≤ 10^6

More Snowflake interview questions

  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
  • Parallel Courses IIIONSITE INTERVIEW · Seen Nov 2026
  • Safest Shortest Path Through a GridOA · Seen Nov 2026
  • Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
  • LFU CacheOA · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
  • Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
  • Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Lowest Common Ancestor with a Changing RootInfosys · OAInfosys interview questions
  • Minimum Tree Diameter After Removing K LeavesMathWorks · OAMathWorks interview questions
  • Special Diameter EndpointsAgoda · OAAgoda interview questions
  • Tree Pythagorean TriplesIBM · OAIBM interview questions
  • Maximum Data Transfer TimeMicrosoft · OAMicrosoft interview questions
  • Longest Transfer Time in a Server TreeRippling · OARippling interview questions
  • Distance Between Two Tree NodesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Diameter of an Acyclic Undirected GraphSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Binary Tree Nodes at Distance KApple · ONSITE INTERVIEWApple interview questions
  • Find the Tree DiameterAdyen · ONSITE INTERVIEWAdyen interview questions

Snowflake interview experiences

  • Snowflake AI Coding Interview, Experienced Hires: 3 Experiences
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public int[] findMaximumNumberLiveThreads(int service_nodes, int[] service_from, int[] service_to, int k, int[][] currentValues) {
        // write your code here
    }

}
Checking account…