- 1
Fixing the reverse list of groups of array
Help me fix my code. My code is working but it didn't give me my desired result. Below are my desired output. Ex. Input: (Enter the size of array} 5 (Enter the integers) 4 7 8 1 9 Output: [9,1]-[8]-[7,4] Ex2. Input: (Enter the size of the array) 7 (Enter integers) 1 2 3 4 5 6 7 Output: [7,6,5]-[4]-[321] The first example is satisfied, but the 2nd example is not. Please help. This is my code: https://code.sololearn.com/c1A167a244A1
2 Answers
+ 2
Evan Fernandez
You can solve like JayakrishnađŽđł said but I don't think that would be possible with your logic so I have tried like this since there is fix middle element
https://code.sololearn.com/cfhTguBgkUOh/?ref=app
+ 2
You are doing list of 2 numbers only.
The logic need there is to add [last N/2 numbers + [middle number] + [First N/2 numbers]
Hope it helps to solve it.