A map of village is split into a rectangular grid with N rows (numbered from 0 - N - 1) and
M columns (numbered from 0 to M - 1). Establish at most two rice cultivation areas in the village, using
only cells dedicated to this purpose.
The map is described by an array of strings: the C-th character of the R-th string can be either '#' if it is an agricultural building.
The shape of the cultivation areas should be a narrow rectangle (vertical with one cell width or horizontal with one cell height).
What is the maximum number of cells that can be used for cultivation by choosing at most two areas?
Given an array of strings A, returns an integer: the maximum number of cells that can be used for cultivation by choosing at most two areas.
A = [".##..", ".#.#.", ".....", "##..#"] return = 7

A = ["#.#", "...", "#.#"] return = 4

A = ["###..", ".....", "###.#"] return = 7

N is an integer within the range [1..500]all strings in A are of the same length M within the range [1..500]all strings in A consist only of the characters '.' and/or '#'- Rank Open BusinessesPHONE SCREEN · Seen May 2026
- Retain Top K ValuesPHONE SCREEN · Seen May 2026
- In-Memory SQL with CSV InitializationONSITE INTERVIEW · Seen May 2026
- Order Records by Matching Start and EndONSITE INTERVIEW · Seen May 2026
- Recover Corrupted Master PageONSITE INTERVIEW · Seen Feb 2026
- Distinct Number Line MovesOA · Seen Oct 2025
- Get Minimum TimeSeen Jun 2025
- Count Subarrays with Bitwise OR PresentSeen Jun 2025
public int maximumCells(String[] A) {
// write your code here
}