-
Notifications
You must be signed in to change notification settings - Fork 0
My LeetCode solutions
License
redouane-nouri/leetcode
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
#include <algorithm>
#include <string>
class Solution {
public:
std::string licenseKeyFormatting(std::string s, int k) {
std::string upperChars, ans;
int count = 0;
for (char &c : s)
if (c != '-')
upperChars += toupper(c);
for (int i = upperChars.size() - 1; i >= 0; --i) {
if (count == k) {
ans += '-';
count = 0;
}
ans += upperChars[i];
++count;
}
std::reverse(ans.begin(), ans.end());
return ans;
}
};
About
My LeetCode solutions
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published