解法一:暴力破解给定两个字符串A和B,问B字符串的每个字符是否都在A字符串中。
for (int i=0; i解法二:hash法 采用HashSet去存储当前A字符串所有元素,依次遍历B字符串,看是不是每个元素都在HashSet中
for (int i=0; i < A.length; i++){ set.add(A.charAt(i)); } for (int j=0; j< B.length; j++){ if (!set.contains(B.charAt(j))){ return false; } } return true;解法三:无空间辅助法将HashSet替换成一个整数,
int hash = 0; for (int i = 0; i < A.length(); ++i) { hash |= (1 << (A.charAt(i) - 'A')); } for (int i = 0; i < B.length(); ++i) { if ((hash & (1 << (B.charAt(i) - 'A'))) == 0) { return false; } } return true;



