View Code of Problem 3857

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        for (int i = 0; i < T; i++) {
            int n = scanner.nextInt();
            int[] nums = new int[n];
            int count = 0;
            for (int j = 0; j < nums.length; j++) {
                nums[j] = scanner.nextInt();
                if (nums[j] == 2)count++;
            }
            System.out.println(count);
        }
    }
}

Double click to view unformatted code.


Back to problem 3857