We're going to make our own Contacts application! The application must perform two types of operations:
add name, where is a string denoting a contact name. This must store as a new contact in the application.
find partial, where is a string denoting a partial name to search the application for. It must count the number of contacts starting with and print the count on a new line.
Given sequential add and find operations, perform each operation in order.
Operations are requested as follows:
Three operations include the names 'ed', 'eddie', and 'edward'. Next, matches all names. Note that it matches and counts the entire name 'ed'. Next, add 'edwina' and then find 'edw'. names match: 'edward' and 'edwina'. In the final operation, there are names that start with 'a'. Return the array .
Complete the contacts function below.
contacts has the following parameters:
string queries[n]: the operations to perform
int: the results of each find operation
The first line contains a single integer, , the number of operations to perform (the size of ).
Each of the following lines contains a string, .
and contain lowercase English letters only.
The input does not have any duplicate for the operation.
4 queries size n = 4
add hack queries = ['add hack', 'add hackerrank', 'find hac', 'find hak']
Add a contact named hack.
Add a contact named hackerrank.
Find the number of contact names beginning with hac. Both name start with hac, add to the return array.
Find the number of contact names beginning with hak. neither name starts with hak, add to the return array.