Question: JAVASCRIPT Problem Statement: Given an array representing a sequence in the forest, identify the maximum number of consecutive 'rabbit' elements without any intervening 'rock' elements.

JAVASCRIPT
Problem Statement:
Given an array representing a sequence in the forest, identify the maximum number of consecutive 'rabbit' elements without any intervening 'rock' elements.
Input Format:
An array forest where each element is either 'rabbit' or 'rock'.
Output Format:
An integer representing the length of the longest continuous sequence of 'rabbit'.
Examples:
Example 1:
Input: forest =['rabbit', 'rabbit', 'rock', 'rabbit', 'rabbit', 'rabbit']
Output: 3
Example 2:
Input: forest =['rabbit', 'rock', 'rabbit', 'rabbit', 'rock', 'rabbit']
Output: 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!