Yelp logo

Yelp Software Engineer Coding Questions

16 practice questions for Yelp Software Engineer 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
Want to practise this one?
Create a free account to open the full question and practise Yelp questions with AI.
Sign up free
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 Hard heap #1

1. [AI Enabled Coding] Business Messaging Demand Leaderboard


Yelp connects consumers with local businesses through messaging and quote requests. In this exercise, build an internal leaderboard that helps operations teams identify businesses receiving the most messages, then extend it so repeated message deliveries and bursts from one consumer do not inflate the demand signal. You may use an AI assistant while coding, but you are responsible for validating its design and results; the scoring policies below are exercise assumptions, not claims about Yelp's production policies.
Part 1 — Raw message leaderboard
  • Each record has exactly four string-valued fields: sender_id, business_id, message, and minute. minute is a nonnegative integer represented as a string.

  • RAW_COUNT: every record contributes exactly 1 to its business's received-message count, including identical records.

  • Return at most k businesses with at least one record, ordered by received count descending, then business_id lexicographically ascending.

  • k = 0 produces an empty leaderboard. In this stage, count the entire batch and ignore timestamps.

  • Implement rank_business_messages(records: list[dict[str, str]], k: int). The return type is up to you; the examples use a JSON object containing leaders.


Example 1:
Input:
{
  "records": [
    {"sender_id": "u1", "business_id": "a", "message": "quote", "minute": "10"},
    {"sender_id": "u1", "business_id": "a", "message": "quote", "minute": "11"},
    {"sender_id": "u1", "business_id": "a", "message": "hours", "minute": "12"},
    {"sender_id": "u2", "business_id": "b", "message": "table", "minute": "13"},
    {"sender_id": "u3", "business_id": "c", "message": "menu", "minute": "14"}
  ],
  "k": 2
}

Output:
{
  "leaders": [
    {"business_id": "a", "received": 3},
    {"business_id": "b", "received": 1}
  ]
}

Explanation: All three records for a count, including the repeated quote. Businesses b and c each receive 1 message; b wins the lexicographic tie for the second position.
Part 2 — Rolling, deduplicated demand snapshots
Operations now needs many historical snapshots, with a demand score resistant to repeated deliveries and sender bursts. Preserve Part 1's behavior and add rank_message_windows(records: list[dict[str, str]], query_times: list[str], k: int).
Before implementing, discuss how your return type changes to represent multiple snapshots and explain why a single received count is no longer sufficient. Your approach must be flexible enough to support future message-equivalence policies, per-sender caps, and diagnostic rules without rewriting the window-processing engine.
  • For each query time t, independently consider records in the exact window t - 60 < minute <= t. Input records and query times can be unsorted. Return snapshots in the original query order, including repeated query times.

  • received remains the raw number of records for the business in that window.

  • DEDUPLICATE: two active records represent the same unique message exactly when their sender_id, business_id, and message strings are equal. Their timestamps do not need to match. A unique message remains active until its last copy leaves the window.

  • unique is the number of distinct messages after that deduplication. For each sender, let u be their unique-message count for that business in the window.

  • SENDER_CAP: the sender contributes min(u, 2) to the business's score. Sum those contributions across senders.

  • Rank businesses with at least one active record by score descending, then business_id lexicographically ascending. Return at most k businesses.

  • For each returned business, include received, unique, score, and rules. Include DUPLICATE_MESSAGE exactly when received > unique, and SENDER_CAP exactly when unique > score. List rule names lexicographically; otherwise return an empty list.

  • Each snapshot includes as_of, preserving the query's original string, and leaders. An empty window produces an empty leaders list.

  • Do not rescan all records or sort all active businesses for every query. Design for large batches and a small total requested output.


Example 2:
Input:
{
  "records": [
    {"sender_id": "u1", "business_id": "a", "message": "quote", "minute": "10"},
    {"sender_id": "u1", "business_id": "a", "message": "quote", "minute": "11"},
    {"sender_id": "u1", "business_id": "a", "message": "hours", "minute": "12"},
    {"sender_id": "u1", "business_id": "a", "message": "patio", "minute": "13"},
    {"sender_id": "u2", "business_id": "b", "message": "table", "minute": "14"},
    {"sender_id": "u3", "business_id": "b", "message": "menu", "minute": "15"}
  ],
  "query_times": ["15", "72"],
  "k": 2
}

Output:
{
  "snapshots": [
    {
      "as_of": "15",
      "leaders": [
        {"business_id": "a", "received": 4, "unique": 3, "score": 2, "rules": ["DUPLICATE_MESSAGE", "SENDER_CAP"]},
        {"business_id": "b", "received": 2, "unique": 2, "score": 2, "rules": []}
      ]
    },
    {
      "as_of": "72",
      "leaders": [
        {"business_id": "b", "received": 2, "unique": 2, "score": 2, "rules": []},
        {"business_id": "a", "received": 1, "unique": 1, "score": 1, "rules": []}
      ]
    }
  ]
}

Explanation: At 15, a has 4 deliveries but only 3 unique messages from u1, so its score is min(3, 2) = 2; both diagnostics fire. Business b scores min(1, 2) + min(1, 2) = 2, and a wins the tie. At 72, the window is (12, 72]: the record at 12 is excluded, leaving only patio for a, while both records for b remain. Their scores are therefore 1 and 2.
Example 3:
Input:
{
  "records": [
    {"sender_id": "u1", "business_id": "a", "message": "quote", "minute": "0"},
    {"sender_id": "u1", "business_id": "a", "message": "quote", "minute": "1"},
    {"sender_id": "u1", "business_id": "a", "message": "hours", "minute": "2"},
    {"sender_id": "u1", "business_id": "a", "message": "patio", "minute": "3"},
    {"sender_id": "u2", "business_id": "b", "message": "menu", "minute": "60"}
  ],
  "query_times": ["60", "59", "61", "121"],
  "k": 2
}

Output:
{
  "snapshots": [
    {
      "as_of": "60",
      "leaders": [
        {"business_id": "a", "received": 3, "unique": 3, "score": 2, "rules": ["SENDER_CAP"]},
        {"business_id": "b", "received": 1, "unique": 1, "score": 1, "rules": []}
      ]
    },
    {
      "as_of": "59",
      "leaders": [
        {"business_id": "a", "received": 4, "unique": 3, "score": 2, "rules": ["DUPLICATE_MESSAGE", "SENDER_CAP"]}
      ]
    },
    {
      "as_of": "61",
      "leaders": [
        {"business_id": "a", "received": 2, "unique": 2, "score": 2, "rules": []},
        {"business_id": "b", "received": 1, "unique": 1, "score": 1, "rules": []}
      ]
    },
    {"as_of": "121", "leaders": []}
  ]
}

Explanation: At 59, a has 4 deliveries, 3 unique messages, and score min(3, 2) = 2, triggering both rules. At 60, the copy at minute 0 expires, but the copy at minute 1 keeps quote active: received = unique = 3, while the score remains 2. At 61, the last quote copy expires, giving received = unique = score = 2. The record at minute 60 is included at times 60 and 61, but excluded at 121. Despite processing times chronologically internally, return snapshots in the requested order.
Notes:
  • There are at most 200,000 records and 200,000 queries; 0 <= k <= 200,000. The total number of returned leaderboard entries is at most 200,000.

  • Inputs satisfy the schema. IDs are nonempty ASCII strings; messages use exact, case-sensitive string equality. Integer minute values are between 0 and 1,000,000,000.

  • Work in memory on a complete batch. Distributed execution, persistence, and concurrent updates are out of scope.
Want to practise this one?
Create a free account to open the full question and practise Yelp questions with AI.
Sign up free
coding Medium hash map #2

2. 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 #3

3. 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 #4

4. 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 #5

5. 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 #6

6. 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 #7

7. [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.

Related Yelp Software Engineer interview prep

Start practicing Yelp questions

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

Get Started Free