Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rohan plays basketball and is part of a league. His team has several matches scheduled. At the beginning of the league, Rohan's coach told him

image text in transcribed

image text in transcribed

image text in transcribed

Rohan plays basketball and is part of a league. His team has several matches scheduled. At the beginning of the league, Rohan's coach told him to write down the match number of every match that their team wins. Rohan followed his coach's instructions but might have written down some match numbers more than once and in random order. One day, Rohan's coach asked him to find out the longest winning streak of their team from the match numbers Rohan wrote down. Your task is to help Rohan find the longest winning streak of his team. Given space-separated numbers representing the match numbers that Rohan noted, write a program to find the longest winning streak of Rohan's team. If there is no winning streak, print 1. Winning Streak refers to the number of consecutive matches won. The longest winning streak refers to the maximum of the winning streaks. Example: If the match numbers noted are 852931 4 , - The winning streaks are 5(1,2,3,4,5) and 2 - The longest winning streak is 5 as it is the maximum among the two winning streaks 5 and 2. Input The input will be a single line containing space-separated integers representing match numbers. Output The output should be a single line containing an integer representing the longest winning streak. Explanation For example, if the given space-separated match numbers are 14 31327151251466 , Winning streaks in 1,4,3,13,2,7,15,12,5,14,6 are 7(1,2, 3,4,5,6,7) and 4(12,13,14,15). - The longest winning streak is 7 as 7 is maximum among 7 and 4 Explanation For example, if the given space-separated match numbers are 14 31327151251466 - Winning streaks in 1,4,3,13,2,7,15,12,5,14,6 are 7(1,2, 3,4,5,6,7) and 4(12,13,14,15). - The longest winning streak is 7 as 7 is maximum among 7 and 4. The output should be 7 . Sample Input 1 1431327151251466 Sample Output 1 Sample Input 2 Sample Output 2 1

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

Step: 3

blur-text-image

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions