GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

This view

  • Original page
  • New address

GeezerVison is showing www.hackerrank.com — Tries: Contacts | HackerRank

We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

We're going to make our own Contacts application! The application must perform two types of operations:

  1. add name, where is a string denoting a contact name. This must store as a new contact in the application.
  2. find partial, where is a string that denotes 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.

Input Format

The first line contains a single integer, , the number of operations to perform.
Each line of the subsequent lines contains an operation in one of the two forms defined above.

Constraints

  • It is guaranteed that and contain lowercase English letters only.
  • The input does not have any duplicate for the operation.

Output Format

For each find partial operation, print the number of contact names starting with on a new line.

Sample Input

4
add hack
add hackerrank
find hac
find hak

Sample Output

2
0

Explanation

We perform the following sequence of operations:

  1. Add a contact named hack.
  2. Add a contact named hackerrank.
  3. Find and print the number of contact names beginning with hac. There are currently two contact names in the application and both of them start with hac, so we print on a new line.
  4. Find and print the number of contact names beginning with hak. There are currently two contact names in the application but neither of them start with hak, so we print on a new line.

Author

dcod5

Difficulty

Hard

Max Score

50

Submitted By

40843

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.