Answered step by step
Verified Expert Solution
Link Copied!

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 k consecutive dark
tiles in the path.
Input :
The first line of input consists of a single integer n denoting
the number of tiles in the path.
Second line consists of space separated n integers. The integers
will be either 1 or 0.1 means light tiles. 0 means dark tiles.
Third line of input consists of a single integer k 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 k consecutive dark tiles then the answer is
0.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

What is the LIFO reserve? What can be learned from it?

Answered: 1 week ago