+ 2

How can i solve this problem please any one can help me i don't understand this question properly given me hint or any idea

Statement: create two arrays A and B of size n. an array A of integers of size n containing positive and negative numbers. array A can contain repeated numbers. Array B contains also n elements each element of array B contains an index from 0 to n-1. So array B doesn’t allow repetation. Your task is to rearrange the array A on the basis of array B. that means if array B contains k on 0th index that means shift the element available on kth index in array A to 0th index of array A. For example, suppose A= 5 7 8 1 9 and B= 1 0 4 2 3 So rearranged array A looks like 7 5 9 8 1. Input: first line contains an integer n denoting number of elements in array A and B Second line contains n integers denoting elements of array A. Third line contains n integers from 0 to n-1 in any order denoting elements of array B. Output: contains rearranged array A. Constraints: 5<=n<=20 Example: 5 5 7 8 1 9 1 0 4 2 3 7 5 9 8 1 https://code.sololearn.com/c347W6IWH3X8/?ref=app I am trying this way ...

25th Apr 2021, 12:28 PM
rahul barhate
rahul barhate - avatar
6 odpowiedzi
+ 5
1. Input a number, size of the arrays; 2. Create the A array for example with any random integer number and in point 1. received size; 3. Create the B array with random integer numbers from 0 till size-1 and each number can be only one time there; 4. Sort the arrays together in one loop over the B array, which items should be sort from min (0) to max (size-1). More hints please after you link here your attempt on SL Playground.
25th Apr 2021, 12:49 PM
JaScript
JaScript - avatar
+ 4
Martin Taylor, thank you for your kind advice. Maybe I do not take the requirements exactly. However, it is my personal interpretation of the task. I don't know what is your business. From this code the questioner could do anything he wants and if not he can always ask. By the way, in my opinion the output of your code does not meet requirement of the task.
26th Apr 2021, 3:50 PM
JaScript
JaScript - avatar
+ 3
Thank you all guys for helping me 😊😊
25th Apr 2021, 2:57 PM
rahul barhate
rahul barhate - avatar
+ 3
For next step and DSA I would you Rahul Barhate recommend following website: https://www.w3schools.com/cpp/cpp_examples.asp
25th Apr 2021, 6:59 PM
JaScript
JaScript - avatar
+ 3
This is my solution with the algorythm as I described above: https://code.sololearn.com/cTnS824Po8NB/?ref=app
25th Apr 2021, 10:12 PM
JaScript
JaScript - avatar
+ 2
Thank you JaScript
26th Apr 2021, 4:41 AM
rahul barhate
rahul barhate - avatar