Category Archives: Data Structures

Lexicographical smallest alternate Array

Given two arrays of element between 0 to N- 1 of length N. Find the lexicographically smallest array c such that for any index i  c[i] = ( a[i] + b[i])%N. To find the lexicographically smallest array we can rearrange the elements of the second array. Example: Input: a[]: {0, 1, 2, 3} b[]: {3, 1, 0, 2} Output:… Read More »