FastPrepSum All Ordered Decimal Concatenations

Sum All Ordered Decimal Concatenations

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA
Learn

Problem statement

Given positive integers values, consider every ordered pair of elements, including pairing an index with itself. Concatenate their decimal representations in pair order and return the sum of all resulting numbers.

Function

sumOrderedConcatenations(values: int[]) → long

Examples

Example 1

values = [2,10,3]return = 1845

The nine ordered concatenations sum to 1845.

Example 2

values = [7]return = 77

The only ordered pair concatenates 7 with itself.

Constraints

  • 1 <= values.length <= 100000
  • 1 <= values[i] <= 1000000000
  • The answer fits in a signed 64-bit integer.

More ZipRecruiter problems

See ZipRecruiter hiring insights
public long sumOrderedConcatenations(int[] values) {
    // Write your code here.
}
values[2,10,3]
expected1845
Checking account…