15% off all plans & roadmaps Use code
See plansProblem editorial
Given an integer array nums, define its concatenation with itself as an array formed by placing all elements of nums first and then placing the same elements again in the same order.
Concatenation of Array is a Array/Matrix Manipulation Patterns problem, in the In-place Rotation subpattern. The pattern covers in-place operations, hashing, prefix sums, spiral traversal, and cyclic sort
The reference solution runs in O(n) time and O(n) space.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Concatenation of Array is a Array/Matrix Manipulation Patterns problem, in the In-place Rotation subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.