mercredi 27 septembre 2017

Array-2 > sameEnds

public boolean sameEnds(int[] nums, int len) {
  boolean res = true;
  for(int i = 0; i<len; i++){
    for(int j = nums.length-len; j<nums.length; j++){
      if(nums[i]!=nums[j]){
        res = false;
      }
    }
  }
  return res;
}

CodingBat result

Can someone please explain why my code is false? I can't figure it out. Thank you!

Aucun commentaire:

Enregistrer un commentaire