Company: KKR_Bank
Difficulty: medium
Split Array into Two Unique Halves Problem Description You are given an array a of n integers, where n is even. Split all of its elements into two arrays, first and second , such that: each element of a goes into exactly one of the two arrays, both arrays have length n / 2 , and neither array contains the same value twice. If no such split exists, report that. Otherwise several splits may be valid, so the split to report is fixed as follows. Walk through a from left to right and label each element 1 (it goes into first ) or 2 (it goes into second ). Among all valid splits, report the one whose label sequence is lexicographically smallest , that is, the one that places an element into first whenever that still allows the rest of the array to be split validly. Each output array lists its elements in the order they appear in a . (inferred -- the source accepts any valid split; this judge compares output exactly, so one split is fixed. It reproduces both of the source's sample answers.) Co