0 out of 464 challenges solved
Write a Python function `find_unique_element(arr)` that takes a sorted array `arr` as input, where every element appears exactly twice except for one element that appears only once. The function should return the element that appears only once. #### Example Usage ```python [main.nopy] print(find_unique_element([1, 1, 2, 2, 3])) # Output: 3 print(find_unique_element([1, 1, 3, 3, 4, 4, 5, 5, 7, 7, 8])) # Output: 8 print(find_unique_element([1, 2, 2, 3, 3, 4, 4])) # Output: 1 ``` #### Constraints - The input array is sorted. - The array contains integers. - The array has a length of at least 1. - There is exactly one element that appears only once.
def find_unique_element(arr): """ Find the element that appears only once in a sorted array. Args: arr (list): A sorted list of integers where every element appears twice except one. Returns: int: The element that appears only once. """ # Implement the function logic here pass