/*Write a program to take an integer array as input. Only one element will be repeated. Print the repeated element. Try to find the result in one single
iteration*/
#include <stdio.h>
int main( ) {
int n;
int arr[ n] , visited[ 100000 ] = { 0 } ; // assuming values are not too large
for ( int i = 0 ; i < n; i++ ) {
if ( visited[ arr[ i] ] == 1 ) { // element already seen → repeated
return 0 ;
}
visited[ arr[ i] ] = 1 ;
}
return 0 ;
}
LypXcml0ZSBhIHByb2dyYW0gdG8gdGFrZSBhbiBpbnRlZ2VyIGFycmF5IGFzIGlucHV0LiBPbmx5IG9uZSBlbGVtZW50IHdpbGwgYmUgcmVwZWF0ZWQuIFByaW50IHRoZSByZXBlYXRlZCBlbGVtZW50LiBUcnkgdG8gZmluZCB0aGUgcmVzdWx0IGluIG9uZSBzaW5nbGUKaXRlcmF0aW9uKi8KI2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBuOwogICAgc2NhbmYoIiVkIiwgJm4pOwoKICAgIGludCBhcnJbbl0sIHZpc2l0ZWRbMTAwMDAwXSA9IHswfTsgICAvLyBhc3N1bWluZyB2YWx1ZXMgYXJlIG5vdCB0b28gbGFyZ2UKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIHNjYW5mKCIlZCIsICZhcnJbaV0pOwoKICAgICAgICBpZiAodmlzaXRlZFthcnJbaV1dID09IDEpIHsgICAvLyBlbGVtZW50IGFscmVhZHkgc2VlbiDihpIgcmVwZWF0ZWQKICAgICAgICAgICAgcHJpbnRmKCIlZCIsIGFycltpXSk7CiAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgIH0KICAgICAgICB2aXNpdGVkW2FycltpXV0gPSAxOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==