FastPrepRestaurant Vote Leaders
Problems/Restaurant Vote Leaders

Restaurant Vote Leaders

ZipRecruiter logoZipRecruiter● EasyFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report includes the base vote count and a weighted follow-up but leaves out a mode parameter, tie order, limits, and empty-input behavior. Our version is about 91% the same as the reported question.

You are given a two-dimensional array of restaurant names, rankings, and a boolean weighted.

Every row is one list of restaurant votes. If the rows do not all have the same length, return an empty array.

  • When weighted is false, every cell contributes 1 point to its restaurant.
  • When weighted is true and a row has m columns, the restaurant at index j receives m - j points. Each row therefore assigns weights m, m - 1, ..., 1.

Return every restaurant whose total score is maximal, in ascending lexicographic order.

Every cell contributes independently, including repeated appearances of the same restaurant within one row. If rankings is empty or its rows contain no names, return an empty array.

Function

restaurantVoteLeaders(rankings: String[][], weighted: boolean) → String[]

Examples

Example 1

rankings = [["a","b","c"],["a","c","d"]]weighted = falsereturn = ["a","c"]

Restaurants a and c each appear twice. They share the maximum score, so both are returned in lexicographic order.

Example 2

rankings = [["a","b","c"],["a","c","d"]]weighted = truereturn = ["a"]

Each row assigns weights 3, 2, and 1. Restaurant a receives 6 points, more than any other restaurant.

Example 3

rankings = [["a","b"],["a"]]weighted = falsereturn = []

The rows have different lengths, so the required result is an empty array.

Constraints

  • 0 <= rankings.length <= 1000
  • Every restaurant name contains between 1 and 50 characters.
  • The total number of cells is at most 100000.
  • If rankings is rectangular, every row has the same number of columns.

More ZipRecruiter Phone Screen questions

  • Neighboring Record IDsPHONE SCREEN · Seen May 2026
  • Most Frequent Word across Grouped ArraysPHONE SCREEN · Seen Sep 2024
  • Starting Value with the Longest Collatz ChainPHONE SCREEN · Seen Apr 2022
  • Classify an Alien Dictionary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Multiset Intersection of Three ListsPHONE SCREEN · Seen Feb 2022
  • Find the Smallest Magic IndexPHONE SCREEN · Seen Dec 2021
  • Website Pair with the Most Common VisitorsPHONE SCREEN · Seen Nov 2021
  • Center-Outward Number SpiralPHONE SCREEN · Seen Jun 2021
  • Missing Ranges within Inclusive BoundsPHONE SCREEN · Seen Feb 2021
  • Fibonacci Number with Constant Extra SpacePHONE SCREEN · Seen Mar 2017

Similar questions at other companies

  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • Values Exclusive to the Current UserMeta · PHONE SCREENMeta interview questions
  • Count Values Appearing Exactly OnceAgoda · PHONE SCREENAgoda interview questions
  • Filter Anagrams of a TargetMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String[] restaurantVoteLeaders(String[][] rankings, boolean weighted) {
        // Write your solution here.
    }
}
Checking account…