Dispatch Virtual Shipping Prices
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.