FastPrepDispatch Virtual Shipping Prices
Problems/Dispatch Virtual Shipping Prices

Dispatch Virtual Shipping Prices

Optimus Information logoOptimus Information● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optimus Information intern onsite interview. The report asks you to implement a virtual function. We made up the standard and express pricing formulas, so you can see which one runs at runtime. Our version is about 75% the same as the reported question.

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

  • 3SumONSITE INTERVIEW · Seen Oct 2026
  • Apply Overridden Integer TransformsONSITE INTERVIEW · Seen Oct 2026
  • Compute Areas Through an Abstract Shape TypeONSITE INTERVIEW · Seen Oct 2026
  • N-Queens Solution CountONSITE INTERVIEW · Seen Oct 2026
  • Two SumONSITE INTERVIEW · Seen Oct 2026

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
All Optimus Information interview questionsSee Optimus Information hiring insights
Saved
class Solution {
    public long[] shippingPrices(int[] weights, String[] service) {
        // Write your code here.
    }
}
Checking account…