Find Minimum Inefficienty
Learn this problemProblem statement
Amazon Web Service has n servers, each of them either has high fault tolerance or high reliability.
A system works better if all the servers have the same attributes. The inefficiency of a group of
server is defined as the number of adjacent pairs of server that have different attributes.
Consider, for example, a set of servers described as 1001001 where '0' means the server has
high fault tolerance, '1' means the server has high reliabiity. The inefficiency of this group is 4 as
described in the image below:
Given a string serverType of length n
consisting of '0', '1', and '?', where '0' means the server has high fault
tolerance, '1' means the server has high reliability, and '?' means you can install any
type of server there, find the minimum inefficiency you can get after install a server at each '?'.
Function
findMinimumInefficiency(serverType: String) → intComplete the function findMinimumInefficiency in the editor.
findMinimumInefficiency has the following parameter:
string serverType: the server typesReturns
int: the minimum possible inefficiency💐 1008th thank you to spike! 👏
Examples
Example 1
serverType = "??011??0"return = 2Example 2
serverType = "00?10??1?"return = 3Constraints
1 <= n <= 10^5serverTypeconsists of'0','1'and'?'only
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026