ZipRecruiter Phone Screening

ziprecruiter logo
ziprecruiter
October 15, 20257 reads

Summary

I had a phone screening interview with ZipRecruiter where I was given a coding challenge to find the maximum occurring restaurant names from a 2D array, handling tie-breakers and a follow-up on weighted occurrences.

Full Experience

My recent phone screening at ZipRecruiter involved a coding question. The interviewer presented a scenario with a 2D array of restaurant names and asked me to identify the name(s) that appeared most frequently. It was crucial to handle situations where multiple names shared the highest frequency by returning all of them. A specific constraint was also mentioned: if the rows in the input array weren't uniform in length, I should return an empty array. Following the main problem, we discussed a follow-up where each restaurant name would have an associated weight, and I needed to explain how I would incorporate these weights into the frequency calculation.

Interview Questions (2)

Q1
Max Occurring Restaurant Names in 2D Array
Data Structures & Algorithms

Given a 2D string array (String[][]) of restaurant names, return the restaurant name(s) that occur with the maximum frequency.

Input Example:

{{"a", "b", "c"},
 {"a", "c", "d"}}

Output Example:

{"a", "c"}

Explanation: "a" and "c" occurred twice each, which is the maximum frequency. "b" occurred once. If there's no tie, return only the single name with max occurrences.

Constraint: If the shape of each row is not the same (i.e., rows have different lengths), return an empty array.

Method Signature:

String[] getRestaurentWithMaxVotes(String[][] res)
Q2
Max Occurring Restaurant Names with Weights
Data Structures & Algorithms

Follow-up: While calculating the vote or score for each restaurant name, include a weight. For example, "a" has weight 3, "b" has weight 2, etc. for the 1st row, and similarly for the second row. How would you adapt the getRestaurentWithMaxVotes function to handle this?

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!