The time complexity is O(1).

Mid element of array is always repeated element.

Example : For even N.

N=4 Repeated element = N / 2 + 1 = 3

ARRAY 1,2,2,2

ARRAY 1 1 1 2

N=8 Repeated element = N / 2 + 1 = 5

ARRAY 1,2,2,4,4,4,4,4

ARRAY 1 2 2 2 2 2 4 5

ARRAY 2 2 2 2 2 3 4 5

Example : For Odd N.

N=3 Repeated element = N / 2 + 1 = 2

ARRAY 1,2,2,

ARRAY 1 1 2

N=7 Repeated element = N / 2 + 1 = 4

ARRAY 1,2,4,4,4,4, 5

ARRAY 2 2 2 2 3 4 5

ARRAY 2 3 3 3 3 4 5