I came across an interview question that required the candidate to count all numbers in an array with the same digits.
for example:

Count all numbers that share the same digits with int input = 394
int[] arr = {1, 14, 101, 349, 439, 745, 934}

the function would return 3, since 439, 934, 349 share the same digits.
The question is how do you solve this in O(log n) time? Im still new to the Big O concept and apart from O(n) and O(n^2)... i am having trouble understanding how to archieve O(log n).

My first thought was as follows:
I would calculate the sum of digits of all elements in the array. If the sum is equal they contain of the same of the digits as the input number.

```
      int counter = 0;

      while (num > 0) {
         int digitSum += num % 10;
         num = num / 10;
      }
      for(int i = 0; i < arr.length; i++) {
      int k = arr[i];

      while (k > 0) {
          int sumOfDigits += k % 10;
          k = k/10;
      }
      if(sumOfDigits == digitSum) {
       counter++;
      }
}

```

I know this would take at least O(n) time but im having trouble finding a better solution.