Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
public boolean has22(int[] nums) {
boolean result=false;
int sum=0;
for(int n:nums){
if(n==2)
result=true;
}
return result;
}
public boolean has22(int[] nums) {
for(int y=0;y<nums.length-1;y++){xxxxxxxxxxx){return true;}}
return false;
}
public boolean has22(int[] nums) {
boolean result=false;
int sum=0;
int len=nums.length;
for(int i=0;i<len-1;i++){
if(nums[i]==2&&nums[i+1]==2)
result=true;
}
return result;
}
You could return true as soon as you find two 2's next to each other and save a little processing time.
public boolean has22(int[] nums) {
// boolean result=false;
int sum=0;
int len=nums.length;
for(int i=0;i<len-1;i++){
if(nums[i]==2&&nums[i+1]==2)
return true;
}
// return result;
return false;
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.