Fixing the reverse list of groups of array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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

16th Jun 2021, 5:11 PM
Eka
Eka - avatar
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
16th Jun 2021, 9:35 PM
A͢J
A͢J - avatar
+ 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.
16th Jun 2021, 6:06 PM
Jayakrishna 🇮🇳