Hacktoberfest Final Week



This content originally appeared on DEV Community and was authored by kkrishnan10

For my final Hacktoberfest contribution, I worked on Issue #18 which was “Rotate Array by K Positions” in the Seed-Pursuit repository. The issue didn’t have a full description, so I interpreted it as the standard DSA problem of rotating an array to the right by k positions.

To prepare, I explored the repository’s structure and confirmed it was written in Java, then set up my local environment and created a new branch for the fix. I reviewed different rotation methods and chose the optimal reverse-based approach, which rotates the array in O(n) time and O(1) space. My implementation reverses the entire array, then the first k elements, and finally the remaining ones, ensuring all cases work even when k exceeds the array length.

The final file, DSA/RotateArrayByK.java, includes a main() method for testing, where users can input n, the array elements, and k, to see the rotated output. Before coding, I researched similar solutions on GeeksforGeeks to verify my approach and syntax. The main challenge was understanding the repo’s submission style and ensuring my code matched its conventions.

Once completed, I pushed my changes to GitHub and created Pull Request. This experience helped me improve my confidence in contributing to open-source projects, practice Git branching and PR etiquette, and apply algorithmic logic in a real project environment.


This content originally appeared on DEV Community and was authored by kkrishnan10