Check if there are any repeated elements in a array recursively
- by devoured elysium
I have to find recursively if there is any repeated element in an integer array v.
The method must have the following signature:
boolean hasRepeatedElements(int[] v)
I can't see any way of doing that recursively without having to define another method or at least another overload to this method (one that takes for example the element to go after or something). At first I thought about checking for the current v if there is some element equal to the first element, then creating a new array with L-1 elements etc but that seems rather inefficient. Is it the only way?
Am I missing here something?