摘要: C: strlen() int main() { const char* str = "I love coding."; printf("%d", strlen(str)); return 0; } C++: str.length() str.size() int main() { string s 阅读全文
posted @ 2020-03-19 19:18 SheepCore 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 1. Description 将一个只含有数字0~9和#的字符串按规则转换: 1. '1' ~ '9' -> 'a' ~ 'i';2. "10#" ~ "26#" -> 'j' ~ 'z' 返回最后字符串res。 2. Solution 顺序扫描字符,每次往后多看两个字符(如果可以的话),判断字符所 阅读全文
posted @ 2020-03-19 16:25 SheepCore 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1. Description 给定一个整数n,求一个包含n个字符的串,串中每个字符出现奇数次。 2. Solution 分类讨论,如果n为1,返回"a",n为2,返回"ab",n大于2且为偶数,则返回"aaaa...aab"(n-1个a加1个b),n为奇数,直接返回n个a。 3. Code stri 阅读全文
posted @ 2020-03-19 15:33 SheepCore 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1. Description 给定一个字符串s,先按从小到大的顺序抽取字符添加到res字符串中,然后按从大到小的顺序抽取字符添加到res末尾,直到原字符串中所有字符抽取完毕。 2. Solution 关键在于先一遍扫描提取每个字符频数,然后向前向后添加,一有字符添加,就要及时将cnt减一。 3. C 阅读全文
posted @ 2020-03-19 15:06 SheepCore 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 1. Description 给定一个字符串 s 是一个只包含 'L' or 'R' 的平衡串(L 和 R 数目一样多),求可以分成多少个平衡子串。 https://leetcode.com/problems/split-a-string-in-balanced-strings/ 2. Soluti 阅读全文
posted @ 2020-03-19 14:16 SheepCore 阅读(164) 评论(0) 推荐(0) 编辑