Unique Array
You are tasked with validating student records from an array RecArray, where each element is in the format
<name>:<roll_no>:<marks>.
The validation rules are given below:
Name: the name should consist only of English alphabets, which words separated by underscore.Each word must start with an uppercase letter, followed by lowercase letters.
Roll Number: The roll number must be unique and a prime number.Marks: The marks should be a positive decimal number with exactly two digits after the decimal point.
Implement a method that should function as a filter for student records, throwing exceptions whenever an invalid record is encountered.
Print the count of exceptions that would be thrown while validating the entire set of student records.
Note
The array RecArray is a collection of strings only separated by a space.
A unique roll number means that no 2 students can have the same roll number.
For unique roll numbers, only check the valid student records only.
The uppercase character in the name may not be followed by a lowercase character.
In case of the same roll number, all students after the first student will throw an exception.
Function description
In the provided code snippet, implement the provided UniqueArray(...) method to print the count of exceptions that
would be thrown while validating the entire set of student records. You can write your code in the space below the
phrase {@literal "WRITE YOUR LOGIC HERE"}
There will be multiple test cases running, so the input and output should match exactly as provided.
The base Output variable result is set to a default value -404 which can be modified.
Additionally, you can add or remove these output variables.
Input format
The first line contains the array RecArray, where each element is in the format <name>:<roll_no>:<marks>.
Sample input
A:3:10.22 Abc_Def:13:12:11 Abc_def:13:11.1 -- denotes RecArray
Constraints
1 < = RecArray.length < = 10000
0 < <name>.length < 100
0 < = <roll no> < = 10000
0.00 < = <marks> < = 100000.00
Output format
The output contains an integer denoting the count of exceptions thrown while validating the entire set of student records.
Sample output
1
Explanation
For 3rd student record
Name: Abc_def (Invalid: 'def' should be 'Def' for proper format)
Roll number: 13 (valid prime number but previously used)
Marks: 11.1 (Invalid format: should have two decimal places)
So, there is only 1 exception.