Interview Question
Share Lesson

# Catch the Hacker

You don’t like studying for coding interviews alone, so before you go to bed you post a signup form online where people can add their email if they want to practice interview questions together. When you wake up, you realize that other people dread studying for interviews as much as you, and A LOT of devs have signed up.

However, some prankster thought it would be funny to mess up your list, and they duplicated every email address multiple times. But this person made a mistake - the algorithm they used to duplicate emails actually created more copies of their email address in the list than anyone else. To get this hacker back, you want to find their email address in the list... using a computationally efficient algorithm! 💪 🙌

Write a function `findHackerEmail` that will return the email address of the hacker.

`` ``

## Breakdown

Share:

1. The brute force solution is O(n2), but you can do better.

2. You may be tempted to sort the list so the duplicate emails are grouped together. Sorts cost O(n log n) which is better than a brute force solution, but think of techniques that allow us to get a better time complexity than this.

3. Using an additional data structure, we can get the time complexity down to O(n).

Share:

Test Results

Run your code and see results here...

### Catch the Hacker

You don’t like studying for coding interviews alone, so before you go to bed you post a signup form online where people can add their email if they want to practice interview questions together. When you wake up, you realize that other people dread studying for interviews as much as you, and A LOT of devs have signed up.

However, some prankster thought it would be funny to mess up your list, and they duplicated every email address multiple times. But this person made a mistake - the algorithm they used to duplicate emails actually created more copies of their email address in the list than anyone else. To get this hacker back, you want to find their email address in the list... using a computationally efficient algorithm! 💪 🙌

Write a function `findHackerEmail` that will return the email address of the hacker.

`` ``