FastPrepAlternating Index Square Sum
Problems/Alternating Index Square Sum

Alternating Index Square Sum

Accenture logoAccenture● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a task that sums squares at alternating positions, and we kept it. We chose the index base, the limits, the examples, and a 64-bit return value. Our version is about 96% the same as the reported question.

Given an integer array values, compute an alternating signed sum of squares:

  • Add values[i]^2 when i is even.
  • Subtract values[i]^2 when i is odd.

Indexes are zero-based. Return the resulting 64-bit integer.

Function

alternatingSquareSum(values: int[]) → long

Examples

Example 1

values = [1,2,3,4]return = -10

The result is 1^2 - 2^2 + 3^2 - 4^2 = -10.

Example 2

values = [5]return = 25

The only element is at even index 0, so its square is added.

Example 3

values = [-2,-3,4]return = 11

Squaring removes the signs, so the result is 4 - 9 + 16 = 11.

Constraints

  • 1 <= values.length <= 10^5.
  • -10^6 <= values[i] <= 10^6.
  • The final result fits in a signed 64-bit integer.

More Accenture interview questions

  • Nearest Composite NumberOA · Seen Sep 2026
  • Minimum Password IncrementsOA · Seen Sep 2026
  • Reduce a Number to One DigitOA · Seen Sep 2026
  • Candy DistributionOA · Seen Sep 2026
  • Customers Who Never OrderedOA · Seen Sep 2026
  • Economical TripOA · Seen Sep 2026
  • Coin ChangeOA · Seen Sep 2026
  • Validate Email AddressOA · Seen Sep 2026
  • Closest Rhyming WordOA · Seen Aug 2026
  • Array Leader ElementsOA · Seen Nov 2025

Similar questions at other companies

  • Confusing Bib NumbersVerily · ONSITE INTERVIEW
  • Plus OneDruva · ONSITE INTERVIEW
  • Rotate a Flat Image ClockwiseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Matrix MultiplicationeBay · ONSITE INTERVIEWeBay interview questions
  • Maximum Product of Three IntegersPelatro · ONSITE INTERVIEW
  • Exact-Sixty Dice Game ValueJane Street · ONSITE INTERVIEWJane Street interview questions
  • Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
  • Moving Cost by Volume and CategoryWayfair · ONSITE INTERVIEWWayfair interview questions
  • Add One to a Number Represented as DigitsOracle · ONSITE INTERVIEWOracle interview questions
  • Streaming Entropy, Part 1: Batch EntropyOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions

Accenture interview experiences

  • Accenture New Grad ASE OA Questions: 15 Experiences
All Accenture interview questionsSee Accenture hiring insights
Saved
class Solution {
    public long alternatingSquareSum(int[] values) {
        // Write your code here.
    }

}
Checking account…