FastPrepList Games by Genre
Problems/List Games by Genre

List Games by Genre

Discord logoDiscord● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names this filtering helper and gives game names and genres. It does not say the output order, what to do when the genre is missing, or whether upper and lower case matter. We chose those rules. Our version is about 92% the same as the reported question.

Given parallel arrays gameNames and genres, return every game whose genre equals inputGenre. The value at genres[i] belongs to the game at gameNames[i].

For this exercise, assume comparisons are case-sensitive and return matching names in their original input order. If no game has inputGenre, return an empty array.

Function

listGamesByGenre(gameNames: String[], genres: String[], inputGenre: String) → String[]

Examples

Example 1

gameNames = ["Cyber Quest","Battle Arena","Sky Adventure","Mystery World","Speed Racer"]genres = ["RPG","Action","Adventure","Puzzle","Racing"]inputGenre = "Action"return = ["Battle Arena"]

Only Battle Arena has the genre Action.

Example 2

gameNames = ["A","B","C","D"]genres = ["Puzzle","RPG","Puzzle","Puzzle"]inputGenre = "Puzzle"return = ["A","C","D"]

The matching games occur at indices 0, 2, and 3, so their names are returned in that order.

Constraints

  • 0 <= gameNames.length <= 10000.
  • genres.length == gameNames.length.
  • Every value in gameNames and genres is non-empty.
  • Comparisons are case-sensitive.
All Discord interview questionsSee Discord hiring insights
Saved
class Solution {
    public String[] listGamesByGenre(String[] gameNames, String[] genres, String inputGenre) {
      // write your code here
    }
}
Checking account…