Question bank › Graphs Dfs
Dsa Graphs Dfs Medium

Garden Path Counts

You are given a garden represented as a grid where each cell can either be a flower ('F') or an empty space ('.'). A flower can only spread to its neighboring cells if they are empty ('.'). Your task is to find how many different ways you can plant flowers such that each flower can only grow into unoccupied adjacent spaces. A flower can grow in any direction horizontally or vertically. Input Format: - The first line contains two integers, m and n, where m is the number of rows and n is the number of columns in the grid. - The following m lines contain n characters, either 'F' or '.'. Output Format: - Print the total number of different arrangements to plant flowers. Example: Input: 3 3 F.F ... F.F Output: 2

Key concepts

graphsdfstreescounting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.