Efficient Deployments
Reported by candidates from Meesho's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Meesho reported this one in June 2026, and the detail that matters is in the statement: the first and nth processors only have one neighbor. That changes which efficiency tier they can ever hit. You get three arrays, noAdjacent, oneAdjacent and bothAdjacent, and you pick a deployment order that maximizes the total. It's a dynamic programming problem wearing a scheduling costume. If you've got an OA invite for this, the goal is to stop thinking about orders and start thinking about neighbor relations. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment.
The problem
A supercomputer has several processors to deploy for execution. They are arranged sequentially in a row from 1 to n. The efficiency of each processor depends on whether its adjacent processors have already been deployed. For processor i, its efficiency is: noAdjacent[i] if neither adjacent processor has been deployed before it. oneAdjacent[i] if exactly one adjacent processor has been deployed before it. bothAdjacent[i] if both adjacent processors have been deployed before it. The first and nth processors only have one adjacent processor. Return the maximum possible sum of efficiencies among all possible deployment orders. Function getMaximumEfficiency(noAdjacent: int[], oneAdjacent: int[], bothAdjacent: int[]) → long Complete the function getMaximumEfficiency. int[] noAdjacent: efficiency values when no adjacent processor was deployed first. int[] oneAdjacent: efficiency values when one adjacent processor was deployed first. int[] bothAdjacent: efficiency values when both adjacent processors were deployed first. Returns long: the maximum possible efficiency sum. Examples Example 1 noAdjacent = [1, 2, 3, 4] oneAdjacent = [4, 4, 2, 1] bothAdjacent = [1, 1, 1, 1] return = 14 One optimal deployment order is 4 -> 3 -> 2 -> 1. The efficiency sum is noAdjacent[4] + oneAdjacent[3] + oneAdjacent[2] + oneAdjacent[1] = 4 + 2 + 4 + 4 = 14. Constraints noAdjacent.length == oneAdjacent.length == bothAdjacent.length n >= 1
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: you don't need to enumerate permutations. Each processor's value depends only on whether its left and right neighbors were deployed before it. So for each adjacent pair, you just decide which one goes first. That's a binary choice per edge, and any set of choices is a valid order because the edges form a path, so there are no cycles. Then DP left to right with state equal to the direction of the edge between i-1 and i. Processor i's tier is the count of neighbors that precede it, which comes from the left edge and right edge directions. The pitfall is the endpoints. Processor 1 and processor n have only one neighbor, so bothAdjacent never applies to them. Handle n=1 separately, where the answer is noAdjacent[0]. Use long for the sum. If the recurrence slips away under the clock, StealthCoder is the hedge during the live OA.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Efficient Deployments cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Meesho's OA.
Meesho reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Efficient Deployments FAQ
What's the trick in Efficient Deployments?+
Reframe the order as one choice per adjacent pair: which processor of the two is deployed first. Each processor's efficiency depends only on how many neighbors precede it. Since the processors form a path, any combination of edge choices is a valid order. Then run a simple left to right DP over those choices.
How hard is this Meesho OA question really?+
Medium. The code is short once you see the edge-direction DP, but the insight takes a minute. Most people waste time thinking about permutations or greedy. Once you see that only neighbor relations matter, it's a two-state DP with O(n) time.
What are the edge cases?+
n=1 returns noAdjacent[0]. For the first and last processors, bothAdjacent is never reachable since they have one neighbor. Also use a 64-bit integer for the total, since the function returns long and sums can overflow 32 bits.
Is greedy enough here?+
No. Picking the best tier for each processor independently can conflict, because deploying i before i+1 affects both of their tiers at once. Neighbor choices are coupled, so you need DP to carry the direction of the previous edge forward.
How do I prepare for this in 48 hours?+
Practice DP on a line where each element's value depends on its neighbors' states, like house robber variants. Then hand-trace Example 1, where the answer is 14 from the order 4, 3, 2, 1. Make sure your DP reproduces that number before you trust it.