Question: Please write a function in Python that determines the longest distance between two perfect square numbers in a list. It should be only 1 loop

Please write a function in Python that determines the longest distance between two perfect square numbers in a list. It should be only 1 loop through the list. Also, creation of any other data types such as a list, dictionary or sets is not allowed. There might be more than 2 perfect square numbers in the list

For example [1,2,3,4] --> should return 3

[2,3,4,6,9,10,11,12,13,14,15,16] --> should return 7

[1,4,2,3,9] --> should return 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!