Question: using python 11. [Programming) Longest Good Segment You're given a set of non-zero, positive integers on a single line Standard Input, each separated by a
11. [Programming) Longest Good Segment You're given a set of non-zero, positive integers on a single line Standard Input, each separated by a space. The first number is M, the lower bound of an interval (inclusive) The second number is N, the upper bound of an interval (inclusive) The remaining numbers are called bad numbers A Good Segment is the longest continuous range of natural numbers between M and N (inclusive), which does not include any bad numbers. Your task: Given an interval and a set of bad numbers, calculate the length of the longest Good Segment and print it to Standard Output. Example Input 1 10 5 4 2 15 Output 5 Explanation The interval is [1,10), inclusive. The bad numbers are (5, 4, 2, 15). All possible segments having no bad numbers: [1, 12, 13, 3), and [6, 10). The longest length segment is (6, 10) having length 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
