No. This is an easy problem, not necessary to use any external memory like-array or others.
You need just to iterate the loop and generate the characters so that you can construct a string following given conditions.
As you are generating characters, you can use ASCII values per iteration with loop to print the characters sequentially (not randomly, otherwise you may confuse).
Again no need to think about the occurrence of exact b numbers of characters in each substrings as you are only generating the b number of characters each time.
Hopeful to your understanding
example: (in C++)
for(int i = 0; i < n; ++i)
cout<<char('a'+i%b);