Amazon OA [ VERY HARD ]

you're writing an android app which merges duplicate contacts from the contact list of the user's phone contact a contact may have following fields name : type : string required/optional: required example : bob parson birth date : type : string required/optional: optional. may be an empty string . format DD-MM-YYYY example 13-10-1999 phones: type : List[string] required/optional: optional . the last may be empty . example :[8888888888, + 919999999999, 102,(022)-2871-5672] last update time: type: integer required/optional: required description: a higher value means a more recent contact. example: 10256 phone numbers: a contact may have zero or more phone numbers present . there could be at max one empty phone number in a contact eg.["8888888888", "", "9999999999"] a given phone number can only appear once in the contact's list .
dulpcates : 2 contacts are considered duplicates if at least one of their non- empty phone numbers matches . merging: contacts should be merged if found to be duplicates .after merging , the more recent contact should remain . the contact should have values present for all fields which had non - empty values in either of the 2 contacts before merging . the phone numbers list of both the duplicates contacts should be merged too . task write a function to read contacts, merge duplicates and print the merged output to console input format: first line contains a single integer N, the number of contacts the next lines contains a string B , the birth-date of the contact the next line contains a single integer P , the total number of phones for this contact the next lines contains P , the total number of phones of this contact the next lines contains P space separated strings , the phone numbers for this contact .if P is 0, this is a blank line . the next lines contains a single integer U, the last update time for the contact output format M group of lines of contact details,where M is number of contacts afer merging each group of lines of merged account details has following format : the first line must contain a single string, the Contact Name the next line must contain a single string . the contact's birth date the next line muat contains the list of the contact' phonr numbers as space separated strings, in ascending order . if phones list is empty, this is a blank line . the next line must contain a single Integer , the contacts's last update time . the contacts must be printed in ascending order of their names note : you will be provided code snippets of function to parse the input from, and to print the output to console .the code snippets will contai logic to print in ascending order too . you are requested not to change the code inside these snippets . doing so may lead to ypur program failing for certian test cases . constraints : 1<=N<=1000 O <= P <= 10 O <-=U <= 1000000 NO TWO CONTACTS IN THE INPUT WILL HAVE THE Same value of U (last update time ) if one of the optional fields is blank,te specific value 'empty' will appear in the input for that field . this may happen for a birthdate or a phone number . the string 'empty' appearing in the input line should be treated as an empty string not a valid value . while printing output , if any of the values is empty, you must print the string 'empty' in its space . assume that all inputs will be in valid format . you don't need to validate the rules . for examplee , assume that are birth-date will be in valid format and you don't need to validate the format

Comments (2)