Skip to content

redouane-nouri/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

408 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

No packages published