loading...

re: Cake and Duplicates VIEW POST

FULL DISCUSSION
 

Nice, creative solution. But since we know that range is 1..n what about

array_sum = [1, 2, 3, 4, 1].sum
consecutive_sum = n∗(n+1)/2

duplicate = array_sum - consecutive_sum

 

Oh shoot! I can’t believe I didn’t think of that. You’re totally right. Nice one! 👍🏻

code of conduct - report abuse