public boolean lucky13(int[] nums) {
for(int y=0;y<nums.length;y++){if(nums[y]==1||nums[y]==3){return false;}}
return true;
}
public boolean lucky13(int[] nums) {
boolean result=false;
int sum=0;
for(int n:nums){
if(n!=1&&n!=3)
result=true;
}
return result;
}
Expected Run
lucky13([0, 2, 4]) → true true OK
lucky13([1, 2, 3]) → false true X
lucky13([1, 2, 4]) → false true X
lucky13([2, 7, 2, 8]) → true true OK
lucky13([2, 7, 1, 8]) → false true X
lucky13([3, 7, 2, 8]) → false true X
lucky13([2, 7, 2, 1]) → false true X
lucky13([1, 2]) → false true X
lucky13([2, 2]) → true true OK
lucky13([2]) → true true OK
lucky13([3]) → false false OK
lucky13([]) → true false X
other tests
X
public boolean lucky13(int[] nums) {
for(int y=0;y<nums.length;y++){if(nums[y]==1||nums[y]==3){return false;}}
return true;
}
public boolean lucky13(int[] nums) {
for (int n:nums) {
if (n==1||n==3)
return false;
}
return true;
}
public boolean lucky13(int[] nums) {
return !Arrays.toString(nums).contains("1")&&!Arrays.toString(nums).contains("3");
}
public class Lucky13 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//lucky13([1, 2, 3]) → false true
System.out.println("value is-->"+lucky13[1, 2, 3] );
}
public boolean lucky13(int[] nums) {
boolean result = false;
int sum = 0;
for (int n : nums) {
if (n != 1 || n != 3)
return false;
}
return true;
}
}
public class Lucky13 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//lucky13([1, 2, 3]) → false true
int[] iA = {1,2,3};
System.out.println("value is-->"+lucky13(iA));
}
public static boolean lucky13(int[] nums) {
boolean result = false;
int sum = 0;
for (int n : nums) {
if (n != 1 || n != 3)
return false;
}
return true;
}
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
ArrayIndexOutOfBoundExcept |
9 | 67 | |
index Out OF Range Exception error | 4 | 53 | |
Re-position sub-options beneath the TAB | 7 | 75 | |
Why method in Java which is called from Runnable run() doesn't need to be 'static'? | 1 | 22 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
21 Experts available now in Live!