Question: An array has each distinct value 3 times contiguously except one value that is exactly 2 times. For example, 8, 8, 8, 2, 2, 2,
An array has each distinct value 3 times contiguously except one value that is exactly 2 times. For example, 8, 8, 8, 2, 2, 2, 0, 0, 0, 3, 3, 3, 7, 7, 6, 6, 6. Your job is to find the value that occurs two times.
a. Write a linear time algorithm that does the job. Your code should be well-commented and variable names should make sense.
b. Write a logarithmic time algorithm that does the job. You can write your code recursively or iteratively. Your code should be well-commented and variable names should make sense.
I need an answer for b, I need a log time algorithm for this job
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
