Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int minLength(int n)
- {
- int ans = n / 26;
- if (n % 26 != 0)
- ans++;
- return ans;
- }
- // Function to find the minimum length String
- string minString(int n)
- {
- int ans = n / 26;
- string res = "";
- while (ans--) {
- res = res + "z";
- }
- if (n % 26 != 0) {
- res = res
- + (char)((n % 26) + 96);
- }
- return res;
- }
- // Driver code
- int main()
- {
- int n = 50;
- cout << minLength(n)
- << endl
- << minString(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment