JuniorArrayMath

Find the Sum of Encrypted Integers

You are given an integer array nums containing positive integers. We define a function encrypt such that encrypt(x) replaces every digit in x with the largest digit in x. For example, encrypt(523) = 555 and encrypt(213) = 333.

Return the sum of encrypted elements.

Example 1
Inputnums = [1,2,3]
Output6
The encrypted elements are [1, 2, 3], and their sum is 1 + 2 + 3 == 6.
Example 2
Inputnums = [10,21,31]
Output66
The encrypted elements are [11, 22, 33], and their sum is 11 + 22 + 33 == 66.

Constraints

  • 1 <= nums.length <= 50
  • 1 <= nums[i] <= 1000

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate