Tap here to switch tabs
Problem
Submissions

Problem: Most Frequent Number Following Key In an Array

Most Frequent Number Following Key In An Array asks you to find the value that occurs most often immediately after the key in an integer array, then return that value.

Statement

You are given an array of integers nums and an integer key.

An integer target follows key if there is at least one index i such that 0≤i<0 \leq i < nums.length −1- 1, nums[i] is equal to key, and nums[i + 1] is equal to target.

Return the integer target that appears the most times immediately after an occurrence of key.

Constraints:

  • 2≤2 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • The test cases are generated such that the answer is unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Most Frequent Number Following Key In an Array

Most Frequent Number Following Key In An Array asks you to find the value that occurs most often immediately after the key in an integer array, then return that value.

Statement

You are given an array of integers nums and an integer key.

An integer target follows key if there is at least one index i such that 0≤i<0 \leq i < nums.length −1- 1, nums[i] is equal to key, and nums[i + 1] is equal to target.

Return the integer target that appears the most times immediately after an occurrence of key.

Constraints:

  • 2≤2 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • The test cases are generated such that the answer is unique.