Associated Course(s):
Sudo Placement 2019

Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have same width and the width is** 1 unit**.

**Input:**

The first line contains an integer 'T' denoting the total number of test cases. T test-cases follow. In each test cases, the first line contains an integer 'N' denoting the size of array. The second line contains N space-separated integers A_{1}, A_{2}, ..., A_{N} denoting the elements of the array. The elements of the array represents the height of the bars.

**Output:**

For each test-case, in a separate** **line, the maximum rectangular area possible from the contiguous bars.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{6}

1 <= A[i] <= 10^{18}

**Example:**

**Input: **

2

7

6 2 5 4 5 1 6

4

6 3 4 2

**Output:**

12

9

**Explanation:
Testcase1:**

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

the_coder95 | 465 |

thanuvinu94 | 388 |

adityasuman2025 | 305 |

Senbonzakura_Kageyoshi | 297 |

PrakharBansal1 | 274 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 724 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.