As the name suggests, the page which is used LEAST RECENTLY i.e. earliest should be replaced.
So all you need to do is:
1. Check whether the new page that has just came in exist in memory
2. If it already exists no need to do the replacement
3. Otherwise replace it.
Let say the page reference string 7 0 1 2 0 3 0 4 2 3 0 3 2 and we have 4 page slots empty.
Initially all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults [7 0 1 2]
0 is already their so —> 0 Page fault. [7 0 1 2]
when 3 came it will take the place of 7 because it is least recently used —>1 Page fault [3 0 1 2]
0 is already in memory so —> 0 Page fault. [3 0 1 2]
4 will takes place of 1 —> 1 Page Fault [3 0 4 2]
Now for the further page reference string —> 0 Page fault because they are already available in the memory. [3 0 4 2]