#include #include #include #include char* solution(int N) { static const int size = (int)('z' - 'a'); const int interval = (int)ceil((double)N / (double)size); char* str = (char*)malloc((N + 1) * sizeof(char)); str[N] = '\0'; int count = 0; char offset = 0; for (int i = 0; i < N; ++i) { str[i] = 'a' + offset; if (++count >= interval) { count = 0; ++offset; } } return str; } int main() { { char* str = solution(3); printf("%s\n", str); free(str); } return 0; }