You are viewing a single comment's thread. Return to all comments →
It's not cheating exactly. Using the same method you can even rotate the array, instead of printing the array just give the values of the array to a new array.
I was nitpicking, I thought of the same soln at first but then changed my mind;
As the question was GIVEN an array ..so if this was an interview there is this constraint that your array is already populated with the elements.
btw r u 14 ? its great to see my young indian frnds indulging in programing