What are some interview questions that a good programmer should be able to solve in 5-15 minutes?

Came up with this. Any other optimal solution.

 public class soln{  

  public static boolean div3(int[] array)
  {

    int sum_of_array = 0;
    for (int n : array)
    {
        sum_of_array += n;
    }

    while (sum_of_array / 10 != 0 ) // not a single digit number
    {
        int temp = sum_of_array;
        int temp_sum = 0;
        while (temp / 10 != 0)
        {
            temp_sum += temp%10;
            temp = temp / 10;

        }
        sum_of_array = temp_sum + temp;
    }
    return sum_of_array == 3 || sum_of_array == 6 || sum_of_array == 9;
  }

public static void main(String[] arrs)
{

    int arr[] = {0};
    System.out.println(div3(arr));

    arr = new int[]{1};
    System.out.println(div3(arr));

    arr = new int[]{3};
    System.out.println(div3(arr));

    arr = new int[]{1,0};
    System.out.println(div3(arr));

    arr = new int[]{1,2};
    System.out.println(div3(arr));

    arr = new int[]{8,4};
    System.out.println(div3(arr));

}
}    

output:

false

false

true

false

true

true

/r/cscareerquestions Thread Parent