If we write the observation on paper, we get something like 01001000100001. The 0s form AP 1,2,3,4… and the 1s are walls placed in between. If we observe the relationship b/w 0 and 1 we see for each group of 0s the 1s appear like this => 0s group = 1 so Ks count = 0, 0s group =2 so Ks count = 1, 0s group 3 so Ks = 2 (0 1 00 1 000). We can write it as K-1. Now we can mathematically write the solution like “Sum of N natural nums” + (k-1). But how? Why are we using Sn? Because if we sum up all groups of 0s we get total 0s and these total zeros represent a portion of the total N that we are trying to find. The other missing part is to find the 1s and for 1s we know k-1 gives us 1s for the 0s that we find using Sn. Now we just have to add these together . So the final mathematical invariance is (k*(k+1))/2 + (k-1). We plug the values and this gives us minium number of n. If in the test case n is greater than or equal to this value that we just calculated then we print “YES” else “NO”