We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here i am dividing input array by 2, if its even then my for loop will traverse lesser than half, if odd then one plus. I have divided the array and will swap the index values, last one will go in first like wise...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays - DS
You are viewing a single comment's thread. Return to all comments →
You dont even need to create a new array, we can just manipulate the existing array and O(n) will be half.
See this implementation in C#:-
Here i am dividing input array by 2, if its even then my for loop will traverse lesser than half, if odd then one plus. I have divided the array and will swap the index values, last one will go in first like wise...