Apply Overridden Integer Transforms
Updated
Problem statement
A base transformer returns x + 1. A derived transformer overrides the same method and returns x * x. For each value, kinds[i] is B or D and selects the runtime object behind a base reference.
Return every transformed value in order.
Function
applyTransforms(values: int[], kinds: String[]) → long[]Examples
Example 1
values = [2,3,-4]kinds = ["B","D","D"]return = [3,9,16]The base object increments while derived objects square.
Example 2
values = []kinds = []return = []Empty input produces empty output.
Constraints
values.length == kinds.length.0 <= values.length <= 100000.|values[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