HomePagev2 › Forums › Python Discussions › Listspractice1
Tagged: #askingquestions

Listspractice1

waiting for any hints for solving this question.

@akondiseetharam like @Kadhir I took have the same question, what is your question. The best way to ask is by posting the question and the your attempt or idea. Not everyone has seen the quiz questions. Please, post the question itself and your idea/ logic.

Sorry for not asking the question clearly.
**Given a list of integers, find the length of the longest range of consecutive integers that are contained in the sorted version of the list.
In the question in a practice quiz. There was a list and we need to sort it. At that point I used .sort() to convert all the list elements into ascending order.
But, after that I need to search for the longest range of consecutive integers.
What I need to do now?
By taking this list as an example
[1,3,5,10,13,14,15]
MY LOGIC:
Is checking the index value of a number, and the next consecutive number should be a increased by +1. So, that I can obtain the numbers from 13,14,15. Finally I need to print the length.
Is this the correct way. or is there any other approach.
Thank you. @satishvadlamani sir and @Kadhir

@akondiseetharam did @narensahu answer help you? Need more tips?

@Kadhir how would you have solved it? Thoughts? I am sure everyone reading this would love to see different perspective
Log in to reply.