defis_contain(self,str1,str2):'''判断一个字符串是否在另外一种字符串中,str1:目标字符串,str2:被查找字符串'''flag=Noneifstr1instr2:flag=Trueelse:flag=Falsereturnflag str1 = "resultCode": "200"; str2 = "{"total":2,"pages":1,"hint":"","resultCode":"200","error":""} 预期结...
*/publicbooleancompareStrings(StringA,StringB){// write your code here//利用哈希表的算法定义数组,因为字符全是大写字母,所以数组大小为26.int[]index=newint[26];//将字符串A中的字符出现个数记录在数组中for(int i=0;i<A.length();i++){index[A.charAt(i)-'A']++;}//遍历字符串Bfor(int j...
def equal(str1, str2): #比较str1, str2是否字符完全相同,假设只含有小写字母 h = [0] * 26 for ch in str1: h[ord(ch)-ord('a')] += 1 for ch in str2: h[ord(ch)-ord('a')] -= 1 for elem in h: if elem != 0: return False retur...