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 |
---|---|---|---|
hibernate example for saving data | 19 | 43 | |
Tomcat: Unable to run tomcat service. | 2 | 20 | |
How to execute a Python program and gather return output in Java | 2 | 31 | |
Formula for calculating ROI on training | 6 | 30 |
Join the community of 500,000 technology professionals and ask your questions.