Question: PYTHON HW #4: Arrays and Strings / 5. Question 5 saved DESCRIPTION GRADING 15 MY TEST 1 Given a list ist only made up of

HW #4: Arrays and Strings / 5. Question 5 saved DESCRIPTION GRADING 15 MY TEST 1 Given a list ist only made up of the integers 0 and 1, and positive integer k, return the length of the longest contiguous sublist that contains only is given that you may change up to k values from 0 to 1. Example: Ist = [1,1, 1, 0, 0, 0, 1, 1, 1, 1.0), k = 2 outputs 6. Explanation: [1,1,1,0,0.1.1.1.1.1.1] Longest sublist is underlined and bolded numbers were flipped from 0 to 1. Ist = [0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1), k = 3 outputs 10. Explanation: [0, 0, 1.1.1.1.1.1.1.1.1.1, 0, 0, 0, 1, 1, 1, 1] Longest sublist is underlined and bolded numbers were flipped from 0 to 1. Note: Test Case 15 tests efficiency. If it fails try a different approach. - Tip: Make sure that you're not printing anything! It slows your solution down code.py New 1 - def longest_consecutive_ones(lst, k): pass Full Screen
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
