Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve in typescript. Thank you. There is a road consisting of N segments, numbered from 0 to N - 1 , represented by a
Please solve in typescript. Thank you.
There is a road consisting of N segments, numbered from to represented by a string S Segment of the road may contain a pothole, denoted by a single uppercase x character, or may be a good segment without
any potholes, denoted by a single dot,
For example, string x means that there are two potholes in total in the road: one is located in segment and one in segment All other segments are good.
The road fixing machine can patch over three consecutive segments at once with asphalt and repair all the potholes located within each of these segments. Good or already repaired segments remain good after patching them.
Your task is to compute the minimum number of patches required to repair all the potholes in the road.
Write a function:
function solutionS;
that, given a string S of length N returns the minimum number of patches required to repair all the potholes.
Examples:
Given x your function should return The road fixing machine could patch, for example, segments and
Given xxxxxx x your function should return The road fixing machine could patch, for example, segments and
Given
xxxxx your function should return The road fixing machine could patch, for example, segments and
Given xxxx your function should return The road fixing machine could patch, for example, segments and
Write an efficient algorithm for the following assumptions:
N is an integer within the range ;
string is made only of the characters andor
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