Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5765 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4993 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1276 |

@bt8816103042 | 739 |

@rohitanand | 495 |

@codeantik | 479 |

@shalinibhataniya1097 | 472 |

@amrutakashikar2 | 464 |

@thealchemist627 | 456 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@dalwainazism125 | 453 |

@SherlockHolmes3 | 447 |

Complete Leaderboard |

Given an array consisting of** N** positive integers, and an integer **k **.You have to find the maximum product of k contiguous elements in the array. Your task is to complete the function which takes three arguments .The first argument is the array **A[ ]** and second argument is an integer** N **denoting the size of the array** A[ ]** and the third argument is an integer k.The function will return and value denoting the largest product of sub-array of size k.

**Input:**

The first line of input is an integer T denoting the no of test cases. Then T test casesfollow . The first line of each test case are two integer N and K separated by space .The next line contains N space separated values of the array A[ ].

**Output:**

Output of each test case will be an integer denoting the largest product of subarray of size k.

**Constraints:**

1 <=T<= 100

1 <=N<= 10

1 <=K<= N

1<=A[]<=10

**Example:
Input**

1

4 2

1 2 3 4

12

The sub-array of size 2 will be 3 4 and the product is 12.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Largest product

...