Optimized the algo. Recurses at maximum 1 ->> O(1)