Student Grades

Company: Cisco_25feb

Difficulty: easy

Problem Statement

Student Grades A classroom is described by the number of students n and an array grades holding the grade of every student. Report three quantities about that classroom: maximum — the highest grade in the classroom. second maximum — the runner-up grade, taken with multiplicity . Sort the grades in non-increasing order; the second value of that list is the answer. So when the highest grade is shared by two or more students, the second maximum equals the maximum. XOR — the bitwise exclusive-or of all n grades. Input Format The first line contains a single integer n , the number of students. The second line contains n space-separated integers, the grades. Output Format Print three space-separated integers on a single line: the maximum grade, the second maximum grade, and the XOR of all grades — in that order. Constraints 2 <= n <= 10^3 1 <= grades[i] <= 10^3 Examples Example 1 Input: 3 1 2 3 Output: 3 2 0 Explanation: The highest grade is 3 and the runner-up is 2 . The XOR is