AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Strictly breaks zip4/1/2024 If it works, fine, but if not try deleting the earlier or later offending elements. Then one algorithm that would work is to check the original list. Otherwise, return the index of the earlier element: this will be a value from 0 to n-2. Make a routine first_bad_pair(sequence) that checks the list that all pairs of elements are in order. You have a right idea, checking consecutive pairs of elements that the earlier element is less than the later element, but more is required. My code: def almostIncreasingSequence(sequence):īut it can't pass all tests. Alternately, you can remove 2 to get the strictly increasing sequence. You can remove 3 from the array to get the strictly increasing sequence. There is no one element in this array that can be removed in order to get a strictly increasing sequence.įor sequence, the output should be: almostIncreasingSequence(sequence) = true. Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.įor sequence, the output should be: almostIncreasingSequence(sequence) = false
0 Comments
Read More
Leave a Reply. |