This downside was requested within the OA rounds of Gojek throughout my On-campus internship in 2022. The issue assertion goes as follows:
- There are n processes that should be assigned to m processors such that the kth processor ought to have the utmost variety of processes (the kth processor is probably the most environment friendly one). Additionally, every processor should be assigned at the very least one course of and the variety of processes assigned to the adjoining processors should not exceed 1. You should discover the utmost variety of processes that may be assigned to the kth processor following all of the given constraints.
This downside will not be obtainable anyplace over the web, so once I solved it, I made a decision to contribute it right here in order that others can consult with it and get a glimpse of what sort of questions are requested within the OAs.Â
At first, this query regarded a bit difficult, however after giving it a while, I bought the binary search strategy to resolve the issue.Â
The C++ code is as follows:
C++
|