Count is to keep track of the total parentheses added so far (i.e. the position in the output string where the new parentheses is to be added).
Code is creating the parentheses one by one untill all the permissible left and right parentheses are used up. so, the two parameters passed lt & rt are remaining left and right parentheses respectively. There are two conditions when additional parantheses can be added -
- Left : when there is any (>0) left par is remaining (still to be added)
- Right : when number of right remaining is greater than number of left remaining (i.e. more left has been used already)
I hope this clarifies.