jeudi 28 février 2019

proxy in class room java programming

    there is voice recorder which store student voice as per roll number on which it was heard earlier. When the attendance process is 
    complete, it will provide a list which would consist of the number of distinct voices.
    teacher presents the list to you and asks for the roll numbers of students who were not present in class. 

    i am trying to find out roll number of absent students in increasing order.

i wrote this case but some test cases are failing. i am not sure what values would be in list which is provided by teacher.

    there are only two inputs :
    1. no of student
    2. result from voice recorder

So can anyone tell what is missing here

public static void main(String args[] ) throws Exception {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
                 List<Integer> ll = new ArrayList<>();
                 List<Integer> input = new ArrayList<>();
                 for (int i = 1; i <= n; i++) {
                        ll.add(i);
                    }

                 String  lines = br.readLine();    

                    String[] strs = lines.trim().split("\\s+");

                    for (int i = 0; i < strs.length; i++) {
                        input.add(Integer.parseInt(strs[i]));
                    }
             for(int i=0;i<ll.size();i++)
                    {

                        if(input.contains(ll.get(i)))
                        {
                            continue;
                        }
                        else {
                            System.out.print(ll.get(i));
                       if(i!=ll.size()-1)
                                    System.out.print(" ");  




Aucun commentaire:

Enregistrer un commentaire