Saturday, February 6, 2016

reverse3 --- Answer to a codingbat's practice problem

This is an answer code for a problem of codingbat; http://codingbat.com/prob/p112409

public int[] reverse3(int[] nums) {
  int[] numsRev = new int[nums.length];
  int j = nums.length-1;

  for(int i = 0; i <= nums.length-1; i++){
    numsRev[i] = nums[j];
    j--;
  }

  return numsRev;
}