![]() |
VOOZH | about |
Given two arrays of equal size, an integer array a[] and a character array b[], each character is associated with an integer at the same index.
Example:
Input: a[] = {3, 1, 2}, b[] = {'G', 'E', 'K'}
Output: {'E', 'K', 'G'}
Explanation: After sorting the integer array a[] in ascending order as {1, 2, 3}, the characters in b[] are rearranged to match this order, resulting in {'E', 'K', 'G'}.
Follow these steps to sort the character array according to the integer array:
Sorted character array: [E, K, G]
Note: The sorting order can be either ascending or descending based on the problem requirement or user’s choice.