Informatica Coding Round Question
Question Details
Given an array with n elements and an integer k. Divide the array into subarrays, each of them containing k elements.For example:Input: arr[]={1, 32, 5, 6, 9, 3} and k=2Th...
Full Details
Given an array with n elements and an integer k. Divide the array into subarrays, each of them containing k elements.For example:
Input: arr[]={1, 32, 5, 6, 9, 3} and k=2 The subarrays will have elements: {1,32}, {5,6}, {9,3}. Now sort these subarrays as {5,6}, {9,3}, {1,32}. Merge these subarrays together and display them as the elements of original array in sorted order as Final output: arr[]={5, 6, 9, 3, 1, 32} Examples:
Input : arr[]={1, 32, 5, 6, 9, 3} k=2 Output : arr[]={5, 6, 9, 3, 1, 32} Below is the implementation of the above idea: CPP // C++ Program implementation of the above idea #include
return 0 ; // This code is contributed by Siddhant Thapliyal }
Output 5 6 9 3 1 32
About This Question
This is a reported interview question from a informatica interview for a swe role during the technical round reported in 2024.
It covers the following topics: Arrays, Strings, Sorting .
Difficulty rating: Easy