Skip to content
← Back to Community
7.4. Lists: Same sign neighbors
Profile icon
pole55

Given a list of non-zero integers, find and print the first adjacent pair of elements that have the same sign. If there is no such pair, print 0.

Example input #1
-1 2 3 -1 -2

Example output #1
2 3

Example input #2
1 -3 4 -2 1

Example output #2
0

Voters
Profile icon
xXweebXx
Profile icon
GeorgeNi
Profile icon
PatadiaKeval
Profile icon
TienDungDung1
Profile icon
MM11MD
Profile icon
KieraYoung
Profile icon
a41689Matilde
Profile icon
yanachernova
Profile icon
Pikachu12
Profile icon
XinranCui