Re: searching for missing element in an array
- From: Moi de Quoi <root@xxxxxxxxxxx>
- Date: Thu, 29 May 2008 20:42:18 +0200
On Thu, 29 May 2008 12:39:08 +0100, rossum wrote:
On Thu, 29 May 2008 03:10:32 -0700 (PDT), srk <kumarsr@xxxxxxxxx> wrote:
Hi,Total all the numbers in the array.
Suppose we have n numbers(from 1 to n) and there is an array of size
n-1. How can we find, which number is missing from the array if numbers
1 to n are being placed in array randomly.
Thanks
SRK
The numbers from 1 to n add up to (n * (n + 1)) / 2.
The difference is the missing number.
rossum
An other option would be to *multiply* all the entries, and divide n! by
the sum ;-)
AvK
.
- Follow-Ups:
- Re: searching for missing element in an array
- From: Stephen Howe
- Re: searching for missing element in an array
- References:
- searching for missing element in an array
- From: srk
- Re: searching for missing element in an array
- From: rossum
- searching for missing element in an array
- Prev by Date: Re: String matching & linear programming...
- Next by Date: Re: searching for missing element in an array
- Previous by thread: Re: searching for missing element in an array
- Next by thread: Re: searching for missing element in an array
- Index(es):
Relevant Pages
|