#力扣LeetCode1704. 判断字符串的两半是否相似 @FDDLC
作者:互联网
题目描述:
1704. 判断字符串的两半是否相似 - 力扣(LeetCode) (leetcode-cn.com)
Java代码:
class Solution {
int[] m=new int['z'+1];
public int count(String s,int bg,int ed){
int cnt=0;
for(int i=bg;i<ed;i++)cnt+=m[s.charAt(i)];
return cnt;
}
public boolean halvesAreAlike(String s) {
for(int e:new int[]{'a','e','i','o','u'})m[e]=m[e-32]=1;
return count(s,0,s.length()/2)==count(s,s.length()/2,s.length());
}
}
标签:bg,两半,int,LeetCode1704,力扣,相似,字符串,FDDLC 来源: https://blog.csdn.net/liuxc324/article/details/119257374