@@ -0,0 +1,1015 @@
+package codingbat.array2;%0A%0A/*%0A * Given an array of ints, return true if the value 3 appears in the array %0A * exactly 3 times, and no 3's are next to each other. %0A * %0A * haveThree(%7B3, 1, 3, 1, 3%7D) = true%0A * haveThree(%7B3, 1, 3, 3%7D) = false%0A * haveThree(%7B3, 4, 3, 3, 4%7D) = false%0A */%0A%0Apublic class HaveThreeTest %7B%0A%0A  public static void main(String%5B%5D args) %7B%0A%0A    HaveThreeTest test = new HaveThreeTest();%0A%0A    System.out.println(%22%3E%22 + test.haveThree(new int%5B%5D %7B3, 1, 3, 1, 3%7D) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.haveThree(new int%5B%5D %7B3, 1, 3, 3%7D) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.haveThree(new int%5B%5D %7B3, 4, 3, 3, 4%7D) + %22%3C%22);%0A  %7D%0A%0A  public boolean haveThree(int%5B%5D nums) %7B%0A    int counter = 0;%0A    %0A    if(nums.length %3C 5)%7Breturn false;%7D%0A    %0A    for(int i=0;i%3Cnums.length-2; i++)%7B%0A      if(nums%5Bi%5D == 3)%7B%0A        if(nums%5Bi+1%5D != 3)%7B%0A          counter++;%0A        %7D%0A      %7D%0A    %7D%0A    %0A    if(nums%5Bnums.length-1%5D == 3 && nums%5Bnums.length-2%5D != 3)%7B%0A      counter++;%0A    %7D%0A    %0A    return counter == 3;%0A  %7D%0A%0A%7D%0A

add task haveThree