Closed Ivan2001otp closed 11 months ago
APPROACH
- I have used two Pointer approach to solve this problem.
- Initially the first pointer will point to second element of vector, and traverses till last second element of vector.
- I will create a pointer immediate previous to the first pointer , now I will check whether the elements of previous pointer and current-pointer are different & element pointed by current pointer and immediate next element is different .
- If this condition satisfies then , I will add the element into the variable and return boolean value specifying that the unique element exists or not.
- Further I have added two conditions to handle , what if first element or last element of vector is unique.
- In any case , if the unique Element does not exist then I have printed the verdict in console.
OUTPUT
- Driver Program
- Util Function
- Input & output results
APPROACH
OUTPUT