Dispatch Virtual Shipping Prices
Updated
Problem statement
A standard pricing object computes 2 * weight. An express pricing object overrides the virtual method and computes 3 * weight + 5. For each shipment, service[i] is S or E.
Invoke the selected object through the shared interface and return all prices.
Function
shippingPrices(weights: int[], service: String[]) → long[]Examples
Example 1
weights = [4,4,10]service = ["S","E","S"]return = [8,17,20]Each call dispatches to the runtime pricing object.
Example 2
weights = []service = []return = []No shipments produce no prices.
Constraints
weights.length == service.length.0 <= weights.length <= 100000.0 <= weights[i] <= 1000000000.
Source note: Author-written prompt excerpt retained for source fidelity.
More Optimus Information Onsite Interview questions
Similar questions at other companies
- Ring Buffer OperationsAmazon · ONSITE INTERVIEW
- Recent Hit CounterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- Path Leaf Character IteratorGoogle · ONSITE INTERVIEWGoogle interview questions
- Randomized Collection with Duplicate ValuesOkta · ONSITE INTERVIEWOkta interview questions
- Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
- Implement MallocNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
- Removal PoolCitadel · ONSITE INTERVIEWCitadel interview questions
- Circuit Breaker State MachineWise · ONSITE INTERVIEW
- Hybrid Run-Length and Bit-Packing EncoderDatabricks · ONSITE INTERVIEWDatabricks interview questions