Interview Question: How to solve the recurrent value problem?

So I was reading an article where the person was talking about the internship interview process and in it, the person was asked 2 algorithm related questions. I decided to solve them myself and see how I would approach such a problem.

Here is the problem — you are given an array of integers [1,2,1,3,3] and you want to find:

    1. The first consecutive recurring number. Then answer of this will be 3.
    2. The first recurring number in the array. The answer of this will be 1.

Continue reading “Interview Question: How to solve the recurrent value problem?”