leetcode482】的更多相关文章

You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. Given a number K, we would want to reformat the strings such that each group contains ex…
这道题主要使用了C++的几个API,大小写转化,字符串替换.其余的逻辑都比较简单.而且经查资料,string类字符串拼接的速度使用+=的速度是很快的.以下代码,也是用的+=来拼接字符串. string licenseKeyFormatting(string S, int K) { transform(S.begin(), S.end(), S.begin(), ::toupper); string oldStr = "-"; string newStr = "";…