Reverse array in groups | SDE Sheet | Arrays
source link: https://www.geeksforgeeks.org/videos/reverse-array-in-groups-sde-sheet-arrays/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
- 120 Views
- 08/04/2022
In this video we will see how to reverse an array in groups of a given size. Say for a given size of 3, we are to reverse the first 3 elements of the array. And then the next three and so on.
Example: Input: arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] k = 3 Output: [3, 2, 1, 6, 5, 4, 9, 8, 7]
Check out the video to see how we implement this!!
Practice Problem: https://practice.geeksforgeeks.org/problems/reverse-array-in-groups0255/1 Article: https://www.geeksforgeeks.org/reverse-an-array-in-groups-of-given-size/ SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK