FastPrepCompute Areas Through an Abstract Shape Type
Problems/Compute Areas Through an Abstract Shape Type

Compute Areas Through an Abstract Shape Type

Optimus Information logoOptimus Information● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optimus Information onsite interview for interns. The report asks to implement abstraction with an abstract type. We chose three shapes and an exact rule for twice the area.

Our version is about 77% the same as the reported question.

Implement an abstract shape contract with an area() operation. Each kind is SQUARE, RECTANGLE, or TRIANGLE. The parallel arrays first and second provide side/width/base and ignored/height/height respectively.

Return twice each shape's geometric area, avoiding fractions: square 2*a*a, rectangle 2*w*h, triangle b*h.

Function

twiceAreas(kinds: String[], first: int[], second: int[]) → long[]

Examples

Example 1

kinds = ["SQUARE","RECTANGLE","TRIANGLE"]first = [3,4,5]second = [0,6,7]return = [18,48,35]

Every concrete shape supplies the same abstract operation.

Example 2

kinds = []first = []second = []return = []

No shapes produce no areas.

Constraints

  • All three arrays have equal length at most 100000.
  • Dimensions are integers in [0, 1000000000].
  • second[i] is ignored for squares.

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
  • Dispatch Virtual Shipping PricesONSITE 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[] twiceAreas(String[] kinds, int[] first, int[] second) {
        // Write your code here.
    }
}
Checking account…