## Friday, 21 August 2020

### How To Find Recurring Sequence In A Fraction

Suppose we have a decimal number. We need to check if the fraction part contains any non-ending repeating sequence or it ends normally.
Let's take an example. Numerator is 5 and denominator is 33.
5 / 33 = 0
5 % 33 = 5

So we need to get the fraction part.
5 * 10 = 50
50 / 33 = 1
Now we have 0.1

50 % 33 = 17
17 * 10 = 170
170 / 33 = 5
So now we have 0.15

170 % 33 = 5
5 * 10 = 50
But we have already done 50 / 33. So if you just think through, we have come back to a previous state where numerator & denominator are same. So we know if we do state transition, we will come back to this state again.
So this is the starting point of the recurring pattern which will continuously go on & never end. So our answer is (15).
Hope it helps in understanding the concept.

### Java Program for Least Common Ancestor Of A Binary Tree

This is common interview question. There can be a variant where we would have to find Least Common Ancestor (LCA) of a Binary Search Tree (B...