Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Interview cake - Find duplicate (space optimization)

def find_duplicate(array)
    mid = array.size/2
    p array.slice(0, mid)
    p array.slice(mid, array.size)
end


p find_duplicate([1, 2, 5, 7, 2, 46]) #2
p find_duplicate([1, 2, 5, 7, 32, 2, 46]) #2

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.