You are given an integer array a1,a2,…,an.
Array b1,b2,…,bk is called to be good if it is not empty and for every i (1≤i≤k) bi is divisible by i
Find the number of good subsequences in a.
I could figure out the recursive O(N2) dp. But i couldnt figure out the iterative version. Can someone help me out on this. Also there is a more optimal approach. Can someone help me figure that out?