FastPrepMinimum Adjacent Merges to Form a Palindrome
Problems/Minimum Adjacent Merges to Form a Palindrome

Minimum Adjacent Merges to Form a Palindrome

Arista Networks logoArista Networks● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Arista Networks full-time online assessment. We kept the operation, the goal, the example, and the two-pointer idea from the report. We added a limit that values are positive. Our version is about 96% the same as the reported question.

In one operation, choose two adjacent array elements and replace them with their sum. Return the minimum number of operations needed to make the resulting array a palindrome.

Function

minMergesToPalindrome(nums: int[]) → int

Examples

Example 1

nums = [12,14,8,13,5]return = 3

Three adjacent merges can produce [26, 26], which is a palindrome.

Constraints

  • 1 <= nums.length <= 10^5
  • 1 <= nums[i] <= 10^9

More Arista Networks interview questions

  • First Missing Number in a Consecutive ArrayOA · PHONE SCREEN · Seen Oct 2026
  • API Bandwidth AllocationOA · Seen Sep 2026
  • LFU CacheOA · Seen Sep 2026
  • Maximum Server Processing TimeOA · Seen Aug 2026
  • Generate Matrix BOA · Seen Jun 2021
  • Remove All Repeated Values from a Linked ListPHONE SCREEN · Seen Oct 2026
  • Trace Nested Object Destruction OrderPHONE SCREEN · Seen Oct 2026
  • Trace Pointer Rebinding and Pointee UpdatesPHONE SCREEN · Seen Oct 2026
  • Swap Adjacent NibblesPHONE SCREEN · Seen Aug 2026
  • Unique Target-Sum Pairs in a Sorted Doubly Linked ListPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Maximum Easy Tasks After RearrangingIBM · OA
  • Latest Arrival to Catch a BusAutodesk · OA
  • Minimum Last-Element RelocationsChubb · OA
  • Generating Login CodesSnowflake · OA
  • Minimum Removals to Balance ArraySalesforce · OA
  • Minimum Storage CapacityAmazon · OA
  • Minimum Machines for TasksExpedia · OA
  • Frog Game 🐸Microsoft · OA
  • Find Minimum Possible SizeMathWorks · OA
  • Minimum Days to Watch All MoviesAdobe · OA
See Arista Networks hiring insights
Saved
class Solution {
    public int minMergesToPalindrome(int[] nums) {
        // Write your solution here.
    }
}
Checking account…