482. License Key Formatting
来源:互联网 发布:胡歌男粉丝知乎 编辑:程序博客网 时间:2024/04/29 00:24
简单字符串处理
class Solution {public: string licenseKeyFormatting(string S, int K) { string NoDashStr; for(int i=0;i<S.size();i++) { if(S[i]!='-') { if(S[i]>='a'&&S[i]<='z') NoDashStr+=S[i]-'a'+'A'; else NoDashStr+=S[i]; } } string result; int begin=0; if(NoDashStr.size()%K!=0) result+=NoDashStr.substr(0,NoDashStr.size()%K)+"-"; begin=NoDashStr.size()%K; while(begin+K-1<NoDashStr.size()) { result+=NoDashStr.substr(begin,K)+"-"; begin+=K; } result.erase(result.end()-1); return result; }};
0 0
- 482. License Key Formatting
- 482. License Key Formatting**
- 482. License Key Formatting
- 482. License Key Formatting
- 482. License Key Formatting
- LeetCode 482. License Key Formatting
- [leetcode] 482. License Key Formatting
- 【Leetcode】482. License Key Formatting
- 482. License Key Formatting (M)
- LeetCode 482. License Key Formatting
- [leetcode]482. License Key Formatting
- [LeetCode]482. License Key Formatting
- LeetCode 482. License Key Formatting
- leetcode 482. License Key Formatting
- leetcode 482. License Key Formatting
- LeetCode笔记:482. License Key Formatting
- [LeetCode] 482. License Key Formatting 解题报告
- 482. License Key Formatting解题报告
- BZOJ 3991 set维护dfs序
- 类加载机制
- 友元类
- PAT
- LeetCode 387. First Unique Character in a String Add to List 题解
- 482. License Key Formatting
- openjudge 8469 特殊密码锁
- 进程优先级管理
- 以太坊私有链搭建及智能合约部署与调用
- 科大第一次淘汰赛
- 机器学习(1) 熵 entropy
- 解决问题
- 初学Hive数据仓库
- C++中的const