no23([4, 5]) → true
no23([4, 2]) → false
no23([3, 5]) → false
Answer 1:
public boolean no23(int[] nums) {Answer 2:
return !(nums[0] == 2 || nums[0] == 3 || nums[1] == 2 || nums[1] == 3);
}
public boolean no23(int[] nums) {
if (nums[0] != 2 && nums[0] != 3 && nums[1] != 2 && nums[1] != 3)
return true;
else
return false;
}
Reference
http://www.javaproblems.com/2013/11/java-array-1-no23-codingbat-solution.html
No comments :
Post a Comment