FastPrepFind a Game's Genre
Problems/Find a Game's Genre

Find a Game's Genre

Discord logoDiscord● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

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

Given parallel arrays gameNames and genres, return the genre of inputGame. The value at genres[i] belongs to the game at gameNames[i].

For this exercise, assume game names are unique and comparisons are case-sensitive. If inputGame does not occur in gameNames, return the empty string.

Function

findGameGenre(gameNames: String[], genres: String[], inputGame: String) → String

Examples

Example 1

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

Mystery World occurs at index 3, so the result is genres[3], which is Puzzle.

Example 2

gameNames = ["Cyber Quest","Battle Arena"]genres = ["RPG","Action"]inputGame = "Unknown Game"return = ""

No game name matches Unknown Game, so the function returns the empty string.

Constraints

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