Yelp logo

Yelp Interview Questions

15 practice questions for Yelp technical interviews

Yelp software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Phrase Tokenizer


Category: String coding problem
Given a string of space-separated words and a dictionary of recognized phrases, split the string into tokens. Phrases in the dictionary represent...
Input: String
Output: Computed result
coding Hard Verified Question #2

2. Conference Buddy Pairing


Category: String coding problem
You are organizing a conference and want to pair up attendees as buddies. Each attendee belongs to a department.
Input: Array of pairs
Output: Integer
coding Medium Verified Question #3

3. Dependency Chain End


Category: Graph coding problem
You are given a list of task dependency pairs [a, b] meaning task a is blocked by task b (i.e., a must wait for b). Each task blocks at...
Input: Graph (nodes and edges)
Output: Computed result
coding Easy Verified Question #4

4. Jaccard Word Similarity


Category: String coding problem
Given two document title strings doc1 and doc2, compute their word-level Jaccard similarity. Split each title into words by spaces and treat each...
Input: String
Output: Computed result
coding Medium Verified Question #5

5. Overlap String Join


Category: String coding problem
Given two code snippet strings s1 and s2, merge them by finding the longest suffix of s1 that exactly matches a prefix of s2. Join the two...
Input: String
Output: Printed output
coding Medium Verified Question #6

6. Product Search Engine


Category: Algorithm coding problem
Design a ProductSearch class for a product catalog search engine. The constructor takes a list of product names. The search(keyword) method...
Input: List
Output: Computed result
coding Medium Verified Question #7

7. Top K Active Customers


Category: String coding problem
You are given a list of support tickets where each ticket is [agent, customer, issue]. A customer's engagement score is the number of unique agents...
Input: List
Output: Computed result
coding Medium Verified Question #8

8. Top K Keyword Products


Category: Algorithm coding problem
You are given a list of product catalog item names and a search prefix. Return the top k item names where at least one word in the name starts with...
Input: List
Output: Array
coding Medium Verified Question #9

9. Traffic Spike Counter


Category: Sliding window coding problem
You are given an array of hourly traffic measurements and a spike detection config. Count how many sliding windows of a given size trigger a spike...
Input: Array
Output: Computed result
coding Medium hash map #1

1. N-Gram Count — Count word occurrences using n-grams

Background: As a platform that aggregates user-generated content, Yelp utilizes n-gram models to analyze user reviews and trends. Effective analysis requires optimized algorithms to process large datasets efficiently.
Problem statement: Write a function that takes a list of strings (user reviews) and an integer n as input and returns a dictionary where the keys are n-grams of size n and the values are their corresponding counts. An n-gram is a contiguous sequence of n items (words) from the text.
Function/class signature:
  • def count_ngrams(reviews: List[str], n: int) -> Dict[str, int]:

Example 1:
Input: reviews = ["The food was great", "Great place for food"], n = 2
Output: {'The food': 1, 'food was': 1, 'was great': 1, 'Great place': 1, 'place for': 1, 'for food': 1}
Explanation: Each contiguous pair of words is counted from the provided reviews.
Example 2:
Input: reviews = ["Good ambiance, good food", "Good service"], n = 3
Output: {'Good ambiance, good': 1, 'ambiance, good food': 1, 'good food Good': 1, 'Good service': 1}
Constraints:
  • 1 <= length of reviews <= 10^4

  • 1 <= n <= 10

  • Reviews are non-empty strings.
coding Medium hash map #2

2. Two Pointers — Find the top N common keywords among Yelp reviews

Background: Yelp's success relies heavily on understanding customer sentiments found in reviews. Extracting common keywords can improve search relevancy and enhance user experience. This exercise focuses on implementing algorithms to discover frequently mentioned keywords.
Problem statement: Given a list of reviews where each review is a string of words, and an integer N, write a function to return a list of the top N most common keywords. Keywords should be considered case-insensitive and you may ignore common stop words like 'the', 'is', 'in', etc.
Function/class signature:
  • def top_n_keywords(reviews: List[str], N: int) -> List[str]:


Example 1:
Input: reviews = ["Great service and food", "Good food but slow service", "Great ambiance and service"], N = 2
Output: ['service', 'food']
Explanation: The words 'service' and 'food' are the most common keywords across the reviews.
Example 2:
Input: reviews = ["Best coffee ever", "This coffee is great", "Excellent coffee and tea"], N = 1
Output: ['coffee']
Constraints:
  • 1 ≤ len(reviews) ≤ 1000

  • 1 ≤ N ≤ 100

  • Each review contains 1 to 10^5 characters.
coding Medium sliding window #3

3. CODING — Find N-grams in a Text

Background: Yelp processes a vast amount of user-generated content daily, and analyzing text data for insights related to reviews can improve features like recommendation systems. N-grams help identify patterns and frequently occurring phrases in user reviews.
Problem statement: Implement a function that returns all n-grams from a given text. An n-gram is a contiguous sequence of n items from a given sample of text. Your function should ignore punctuation and be case-insensitive, returning all unique n-grams sorted in alphabetical order.
Function/class signature:
  • def find_ngrams(text: str, n: int) -> List[str]:


Example 1:
Input: text = "The food is great and the service is excellent", n = 2
Output: ["and the", "excellent", "food is", "great and", "is great", "is excellent", "service is", "the food"]
Explanation: The function extracts 2-grams from the provided text.
Example 2:
Input: text = "Yelp is a service to find great food", n = 3
Output: ["a service to", "find great food", "great food", "is a service", "to find great"]
Explanation: The function extracts all unique 3-grams from the text.
Constraints:
  • 1 <= n <= 10

  • 0 <= len(text) <= 10^5

  • Only alphanumeric characters and spaces will be present in the text.


coding Medium dynamic programming #4

4. Dynamic Programming — Maximum Rating Sum

Background: Yelp aggregates ratings from various users for businesses to provide insights. One of the challenges is determining the maximum sum of ratings obtainable from a subset of users, ensuring no two ratings considered are from users who are too similar (e.g., are friends).
Problem statement: Given an array of integers ratings representing the ratings provided by users, you want to find the maximum sum you can form by choosing elements in a way that no two elements chosen can be adjacent in the original order. You must ensure to select the elements such that the chosen subarray does not include adjacent indices.
Function/class signature:
  • def max_rating_sum(ratings: List[int]) -> int:

Example 1:
  • Input: ratings = [3, 2, 5, 10, 7]

  • Output: 15

  • Explanation: You can select ratings 3 (index 0), 10 (index 3), and 2 (index 1) giving a total of 3 + 10 +2 = 15.

Example 2:
  • Input: ratings = [1, 2, 3, 1]

  • Output: 4

  • Explanation: You select 2 (index 1) and 1 (index 3) yielding 2 + 1 = 3.

Constraints:
  • 0 <= len(ratings) <= 1000

  • 0 <= ratings[i] <= 1000

coding Medium string #5

5. Coding — Finding n-grams in user reviews


Background: Yelp aggregates hundreds of thousands of user reviews on various businesses. To enhance search capabilities and provide more relevant recommendations, Yelp needs to analyze and extract meaningful n-grams from these reviews.
Problem statement: Given a list of reviews (strings) and an integer n, implement a function to find all n-grams (consecutive sequences of n words) from the reviews. The output should be a list of strings representing these n-grams.
Function/class signature:
  • def find_ngrams(reviews: List[str], n: int) -> List[str]:


Example 1:
  • Input: reviews = ['The food was great', 'Great service and great ambiance'], n=2

  • Output: ['The food', 'food was', 'was great', 'Great service', 'service and', 'and great', 'great ambiance']

  • Explanation: The function should return all distinct 2-grams from the reviews provided.


Example 2:
  • Input: reviews = ['Loved the pizza', 'Pizza was too salty'], n=3

  • Output: ['Loved the pizza', 'the pizza was', 'pizza was too', 'was too salty']

  • Explanation: The output lists the distinct 3-grams found in the provided reviews.


Constraints:
  • 1 <= len(reviews) <= 100

  • 1 <= len(reviews[i]) <= 1000

  • 1 <= n <= 10

  • All reviews are non-empty strings.

coding Medium hash map #6

6. [Hash Map] — Find duplicate reviews

Background: Yelp relies on user reviews to provide valuable insights about businesses. Identifying duplicate reviews is crucial to maintaining the integrity and reliability of review data. This problem involves managing and processing large volumes of text data efficiently.
Problem statement: You are tasked with implementing a function that checks for duplicate reviews across a dataset. You should accept a list of strings, where each string represents a review, and return a list of duplicates. The comparisons should be case-insensitive and ignore leading/trailing spaces.
Function/class signature:
  • def find_duplicate_reviews(reviews: List[str]) -> List[str]:

Example 1:
Input: ['Great food!', 'Great food! ', 'Nice service', 'Great food!']
Output: ['Great food!']
Explanation: The review 'Great food!' appears more than once when accounting for case and whitespace.
Example 2:
Input: ['Excellent place', 'Excellent Place', 'Not bad', 'liked it']
Output: []
Explanation: No reviews are duplicates based on the conditions specified.
Constraints:
  • 1 ≤ len(reviews) ≤ 10^4

  • Each review has a length of at most 100 characters

  • Reviews contain printable ASCII characters.

Start practicing Yelp questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free