1446. 连续字符
作者:互联网
1446. 连续字符
遍历一遍即可
class Solution { public int maxPower(String s) { int len = s.length(); if(len <= 0) { return 0; } int max=1,tmp=1; for(int i=1;i<len;i++) { if(s.charAt(i-1) == s.charAt(i)) { tmp++; if(tmp > max) { max = tmp; } } else { tmp = 1; } } return max; } }
标签:tmp,字符,int,max,len,1446,连续 来源: https://www.cnblogs.com/caijiyang/p/15628823.html