I was able to come up with a graph traversal solution but couldn't get all the test cases.
Question:
There are service_nodes of different micro-services in a system with bidirectional connections in the form of a tree (acyclic graph), where the ith edge connects the micro-services service_from[i] and service_to[i]. Each micro-service is configured with a maximum number of live threads that can be present in its lifecycle, where the ith micro-service can have a maximum of threads[i] threads. The micro-services adjacent to each other must have maximum threads differing by exactly 1.
Some configurations were lost, and only k of the micro-services are known. This information is given as a 2D array, currentValues, of size k x 2 denoting [micro-service index, maximum threads], or, [i, threads[i]]
Find the maximum number of live threads that each micro-service can have such that the total number of live threads in the system is the minimum possible. Return an array of length service nodes where the element denotes the maximum number of live threads for the micro-service.
Note: It is guaranteed that the solution always exists.
Constraints 1 <= node_count <= 105 number of given values for nodes <= node_count 1 <= value of a node <= 105
Example
given graph => (1:3)-(2:x)-(3:x)-(4:x)-(5:3) node 1 to 5 (given) for nodes 1 and 5, we have been given the max thread value as 3 and 3, respectively we need to find all x values such that max sum is minimum and adjacent nodes differ by 1 solution for the above graph => (1:3)-(2:2)-(3:1)-(4:2)-(5:3) so we return [3,2,1,2,3]
Videos
Why has the concept of multi threading starting to become so ubiquitous and important in interviews? How does one prepare for them ? I have no idea about it being a non CS graduate!
Okay, I have read/watched jevkov's videos and blogs. But how can i prepare for FAANG interviews? Last time, this interviewer from Goldman had me trippin' answering questions regarding why use singleton pattern, and what occasion I should use multi-threading. But at my job, I did notice there were tests that implements Runnable interface that is multithreaded, and threadcontext on the controller level. So Im not really exposed to multithreading.
Could someone please share some concise resources that gives insights into must know fundamentals of Java Multithreading/concurrency to prepare for FAANG interviews? Thanks