FastPrepMaximum Sum of Exactly Three Non-Adjacent Elements
Problems/Maximum Sum of Exactly Three Non-Adjacent Elements

Maximum Sum of Exactly Three Non-Adjacent Elements

LSEG logoLSEG● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an LSEG online assessment. The task is the largest sum of exactly three elements that are not next to each other. The report does not give the limits on the numbers or the function signature. Our version is about 90% the same as the reported question.

Given an integer array nums, choose exactly three indices i < j < k such that j - i >= 2 and k - j >= 2.

Return the largest possible sum nums[i] + nums[j] + nums[k]. You must choose exactly three elements, even when all values are negative.

Function

maximumThreeSum(nums: int[]) → long

Examples

Example 1

nums = [4,100,7,100,9]return = 20

The only valid triple uses indices 0, 2 and 4, giving 4 + 7 + 9 = 20.

Example 2

nums = [-5,-1,-2,-1,-3,-2]return = -4

Choose indices 1, 3 and 5: -1 + -1 + -2 = -4. Exactly three elements are required.

Example 3

nums = [5,1,10,1,5,1,10]return = 25

Indices 2, 4 and 6 give 10 + 5 + 10 = 25.

Constraints

  • 5 <= nums.length <= 100000.
  • -1000000000 <= nums[i] <= 1000000000.

More LSEG Online Assessment questions

  • Count Times Using at Most Two DigitsOA · Seen Jul 2025
  • Maximum Word Count in a SentenceOA · Seen Jul 2025
  • Minimum Digit Swaps for the Smallest DifferenceOA · Seen Jul 2025
  • Smallest String After at Most One DeletionOA · Seen Jul 2025
  • Delete One Digit 5 to Maximize the NumberOA · Seen Feb 2025
  • Three-Part Partition with Minimum Largest RangeOA · Seen Feb 2025
  • Transform a String with at Most One OperationOA · Seen Feb 2025
  • Price Equity Options and ForwardsOA · Seen Dec 2024
  • Maximum Sum of Non-Adjacent ElementsOA · Seen Sep 2024
  • Return the Sentence with the Most WordsOA · Seen Sep 2024

Similar questions at other companies

  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions
  • Maximum Points by Deleting ElementsIBM · OAIBM interview questions
  • House RobberWalmart · OAWalmart interview questions

Interview reports that mention this question

  • LSEG Graduate Technology OA and Interviews: 7 Experiences
All LSEG interview questionsSee LSEG hiring insights
Saved
class Solution {
    public long maximumThreeSum(int[] nums) {
            // write your code here
        }
}
Checking account…