Tap here to switch tabs
Problem
Submissions

Problem: Find Triangular Sum of an Array

Try to solve the Find Triangular Sum of an Array problem.

Statement

You are given an integer array nums, where each element is a single digit.

The triangular sum of nums is computed by executing the following procedure:

  1. If nums has a length of 11, end the process and return nums[0].

  2. Otherwise, construct a new integer array newNums of length nums.length −1- 1.

  3. For every index i such that 0≤0 \leq i << nums.length −1- 1, assign newNums[i] = (nums[i] + nums[i + 1]) % 1010, where % denotes the modulo operation.

  4. Replace nums with newNums.

  5. Repeat the process until only 11 element remains in nums.

Return the triangular sum of nums.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] ≤9\leq 9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Triangular Sum of an Array

Try to solve the Find Triangular Sum of an Array problem.

Statement

You are given an integer array nums, where each element is a single digit.

The triangular sum of nums is computed by executing the following procedure:

  1. If nums has a length of 11, end the process and return nums[0].

  2. Otherwise, construct a new integer array newNums of length nums.length −1- 1.

  3. For every index i such that 0≤0 \leq i << nums.length −1- 1, assign newNums[i] = (nums[i] + nums[i + 1]) % 1010, where % denotes the modulo operation.

  4. Replace nums with newNums.

  5. Repeat the process until only 11 element remains in nums.

Return the triangular sum of nums.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] ≤9\leq 9