1663.cpp (304B)
1 class Solution { 2 public: 3 string getSmallestString(int n, int k) { 4 string res(n, 'a'); 5 int full = (k - n) / 25, extra = (k - n) % 25; 6 for (int i = 0; i < full; i++) 7 res[n - i - 1] = 'z'; 8 if (extra) res[n - full - 1] += extra; 9 return res; 10 } 11 };