题目描述
Description: 给你一个纯数字字符串s,请返回连续单一数字子串的个数
提示:
1 <= s.length <= 100
输入描述:
“11121”
解释:
只含单一字母的子串分别是:“111” 、“11”, “1” “2”
“111” 出现1次
“11” 出现2次
“1” 出现4次
“2” 出现1次
共 1 + 2 + 4 + 1 = 8
解题思路:
- 先求出所有子串
- 再判断子串是否都是相同字符
/**
* 暴力法
* @param str
* @return
*/
public static int test_1(String str) {
int res = 0;
HashMap<String,Integer> map = new HashMap<>();
for(int i = 0; i < str.</