leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1663.cpp (304B)


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