Neighbours

Given a list of integers (string of integers separated by a space).
To bring the sum of all numbers n from the list, such that in the list there are no n-1 and n+1.

IN

1 2 5 4 3 6 7

OUT

0

IN

2 4 6 8 2

OUT

20

IN

1 8 2 3 5 6 8

OUT

8

IN

1 2 4 8 12 15 7 8 5 9

OUT

27

IN

15

OUT

15

IN

3

OUT

3

Can't understand 2-nd test. Why 20? Why not 22?

Thu Jul 24 00:36:55 2014

And can't understand 3-rd test. Why 8? Why not 16?

May be need to calculate only different numbers?

Thu Jul 24 00:39:16 2014


Leave a comment

Parsed as Markdown

Login to leave a comment