Sort 1 to N by swapping adjacent elements
Given an array A of size N. A boolean array B consisting of N-1 elements indicates that if B[i] is 1 then A[i] can be swapped with A[i+1]. Find if A can be sorted by swapping elements. Examples: Input : A[] = {1, 6, 52, 31, 47, 60} B[] = {0, 1, 1, 1, 0} Output : A… Read More »