Check if an array can be formed by merging 2 non-empty permutations
Given an array arr[] of length N, the task is to check if it can be formed by merging two permutations of the same or different lengths. Print YES if such merging is possible. Otherwise, print NO. Permutations of length 3 are {1, 2, 3}, {2, 3, 1}, {1, 3, 2}, {3, 1, 2}, {3, 2, 1}, {2, 1, 3}. Examples