FastPrepList Games by Genre
Problems/List Games by Genre

List Games by Genre

Discord logoDiscord● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source names this filtering helper and supplies game names and genres, but it does not specify output order, missing-genre behavior, or case normalization. The judged core task matches the visible source at about 92%.

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.

More Discord problems

  • Find a Game's GenreONSITE INTERVIEW · Seen Apr 2026
  • Find Games by Platform CountONSITE INTERVIEW · Seen Apr 2026
  • Find the Most Available GamesONSITE INTERVIEW · Seen Apr 2026
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…