Tap here to switch tabs
Problem
Submissions

Problem: Most Frequent Number Following Key In an Array

med
30 min
Try to solve the Most Frequent Number Following Key In an Array problem.

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

med
30 min
Try to solve the Most Frequent Number Following Key In an Array problem.

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.