Question: Your task is to create a method called findRepeating that takes as a parameter an array of positive integers and returns the only integer

Your task is to create a method called findRepeating that takes as 


Your task is to create a method called findRepeating that takes as a parameter an array of positive integers and returns the only integer in that array that DOES repeat or -1 if there is no repeating integer. Examples If the array passed into your method is... [e, 1, 2, 3, 4, 5, 4, 6, 11] then your method should return 4 as this is the only integer that repeats. If the array passed into your method does not have a repeating integer, your method should return -1, for example: [1, 0, 3, 2, 4] h Your method should return -1 because there is no repeating integer. You can assume that all arrays passed into your method only have at most 1 repeating integer. Expand You may need to use nested loops to solve this problem. If you do use nested loops, be careful to check that you are not comparing the same two elements (i.e. not comparing array[0] with array[0] or array[1] with array[1] for example).

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 Programming Questions!