Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static int[] findTotalShops(int shops,int[]prices,int days,int[] money)
{
int [] totalShops=new int[days];
Arrays.sort(prices);
for(int i=0;i<days;i++)
{
if(money[i]<prices[0])
totalShops[i] = 0;
else if(money[i]>=prices[shops-1])
totalShops[i]=shops;
else
totalShops[i]=binarySearch(prices,0,shops-1,money[i]);
}
}
public static int binarySearch(int []arr,int low,int high,int money)
{
if(arr[low]==money)
return low+1;
if(arr[high]<=money)
return high+1;
int mid=low+(high-low)/2;
int maxShops=-1;
while(arr[mid]==money)
{
maxShops=mid;
mid++;
}
if(maxShops!=-1)
return maxShops+1;
if(arr[mid]>money)
return binarySearch(arr,low,mid-1,money);
else
return binarySearch(arr,mid+1,high,money);
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

int[] arr = new int[input3];
for(int i=0;i<input3;i++)
{
arr[i]=0;
for(int j =0;j<input1;j++)
{
if(input4[i]>=input2[j])
{
arr[i]++;
}
}
}
return arr;

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.