Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Imagine a path that has been paved with shades of light and dark tiles. Each tile's color can be either a dark shade or a
Imagine a path that has been paved with shades of light and dark
tiles. Each tile's color can be either a dark shade or a light
shade. You need to find out the minimum number of light tiles to
be replaced by dark tiles so that there exists consecutive dark
tiles in the path.
Input :
The first line of input consists of a single integer denoting
the number of tiles in the path.
Second line consists of space separated integers. The integers
will be either or means light tiles. means dark tiles.
Third line of input consists of a single integer denoting the
number consecutive dark tiles there has to be in the path
Output:
Output consists of a single integer denoting the minimum number
of light tiles that needs to be replaced with black tiles. If the
path already contains consecutive dark tiles then the answer is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started