Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 468 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

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 the 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 case, the first line contains an integer 'N' denoting the size of the 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 represent the height of the bars.

**Output:**

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

**User Task:**

The task is to complete the function **getMaxArea**() which finds the largest rectangular area possible and **returns** the answer.

**Expected Time Complexity: **O(N).

**Expected Auxiliary Space: **O(N).

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{6}

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

**Example:**

**Input: **

2

7

6 2 5 4 5 1 6

8

7 2 8 9 1 3 6 5

**Output:**

12

16

**Explanation:
Testcase1:**

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
Maximum Rectangular Area in a Histogram

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.