Coder Social home page Coder Social logo

maxrectangularareawithoutholes's Introduction

MaxRectangularAreaWithoutHoles

Problem Description

A farmer has a plot of land with some holes. The farmer wants to build a paling around the largest possible rectangular area that does not contain any holes. What is the perimeter of this largest rectangular area?

Input:

The input consists of two lines. The first line contains two space-separated integers, m and n, the number of rows and columns in the grid, respectively. The second line contains m strings, each of length n, representing the grid. Each character in the grid is either a '.' (representing good land) or an 'x' (representing a hole).

Output:

The output consists of a single integer, the perimeter of the largest possible rectangular area that does not contain any holes. If such an area cannot be constructed, output the string "impossible". Constraints: 1ā‰¤m,nā‰¤200 samples:


Sample Input:

4 5 ..... .x.x. ..... .....

Sample Output:

14


Sample Input:

2 2 .x x.

Sample Output:

Impossible


Sample Input:

2 5 ..... xxxx. ###Sample Output: Impossible

maxrectangularareawithoutholes's People

Contributors

qsrawi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.