FastPrepVan Eck Sequence Term
Problems/Van Eck Sequence Term

Van Eck Sequence Term

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The source gives no upper limit and no function signature. We kept the rule for the sequence, the term you must return, and the sample start of the sequence. Our version is about 99% the same as the reported question.

Given a positive integer n, define a zero-indexed sequence a as follows:

  • a[0] = 0.
  • For every i >= 1, let x = a[i - 1]. If x appeared in a[0..i-2], let j be its greatest previous index and set a[i] = (i - 1) - j. Otherwise, set a[i] = 0.

Return a[n - 1].

Function

vanEckTerm(n: int) → int

Examples

Example 1

n = 1return = 0

The requested term is the initial value a[0].

Example 2

n = 4return = 0

The first four terms are [0, 0, 1, 0], so a[3] = 0.

Example 3

n = 10return = 6

The prefix is [0, 0, 1, 0, 2, 0, 2, 2, 1, 6]. Before index 9, the previous value 1 last appeared at index 2, so a[9] = 8 - 2 = 6.

Constraints

  • 1 <= n <= 1000000.

More Bloomberg LP Onsite Interview questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Transactional Key-Value StoreGrammarly · ONSITE INTERVIEW
  • Invoice / Payment ReconciliationStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Sustained Overspeed AlertsFleetx · ONSITE INTERVIEW
  • Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad Screens: 30 Experiences (Part 4 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int vanEckTerm(int n) {
        // Write your code here.
    }

}
Checking account…