Coca Cola Cool Drink

Kenny loves Coca Cola. There are ‘n’ different shops in his colony from which he can buy coca cola. Each shop has different rate for the same coca cola bottle. Kenny decided to buy his favorite cool drink for ‘m’ continuous days. Each day Kenny has ‘p’ money in his hand. Find out, from how many shops, Kenny can buy his favorite cool drink each day.

Function Description
Complete the function FindTotalShops()
Parameters
  • input1 – Total number of shops in the colony
  • input2 – Rate of cool drink in each shop
  • input3 – Number of days, Kenny is going to buy the cool drink
  • input4 – Total money, Kenny has with him to buy cool drink, each day
Return
Number of shops, in which, Kenny can buy cool drink, each day.
Sample Input
5
3 10 8 6 11
4
1 10 3 11
Sample output
0 4 1 5
Solution in C JAVA PYTHON
#include<stdio.h>
int* FindTotalShops(int, int*, int, int*);
int main() {
  int n,m,prices[20],money[20];
  int* result;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&prices[i]);
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d",&money[i]);
  }
  result = FindTotalShops(n,prices,m,money);
  for(int i=0;i<m;i++){
    printf("%d",result[i]);
    if(i<m-1){
      printf(" ");
    }
  }
}

int* FindTotalShops(int input1,int* input2,int input3, int* input4){
  static int result[20];
  for(int i=0;i<input3;i++){
    int count=0;
    for(int j=0;j<input1;j++){
      if(input4[i]>=input2[j]){
        count++;
      }
    }
    result[i]=count;
  }
  return result;
}