Java
Integer.bitCount(x ^ y)
split()
to count appearance of characters, add blank space
in the beginning and end of the String
firststring.replaceAll("regular expression","")
public int countPrimes_1(int n)
{
boolean[] isPrime = new boolean[n];
for (int i = 2; i < n; i++)
isPrime[i] = true;
for (int i = 2; i * i < n; i++)
{
if (!isPrime[i])
continue;
for (int j = i * i; j < n; j += i)
isPrime[j] = false;
}
int count = 0;
for (int i = 0; i < n; i++)
if (isPrime[i])
count++;
return count;
}
int[] chars = new int[256];
for(char c : s.toCharArray())
{
chars[c]++;
}