pemmasanivara
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
public static int getCount(int num){
int[] data=new int[]{0,0,0,0,0,0,1,1,1,1,2,2,2,3,4,5};
int count=0;
for(int i=0;i<data.length;i++){
if(data[i] == num){
count++;
}else if(data[i] > num){
return count; //If you are done with count,come out of the loop.
}
}
return count;
}
Comment hidden because of low score. Click to expand.
0
of 0 vote
public static int getCount(int num){
int[] data=new int[]{0,0,0,0,0,0,1,1,1,1,2,2,2,3,4,5};
int count=0;
for(int i=0;i<data.length;i++){
if(data[i] == num){
count++;
}else if(data[i] > num){
return count;
}
}
return count;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- pemmasanivara June 17, 2015