Level: Unknown Level
Round: Phone Screen · Type: Coding · Difficulty: 7/10 · Duration: 60 min · Interviewer: Neutral
Topics: Arrays, Subsequences
Location: Remote
Interview date: 2025-12-31
Got offer: False
I was given a number sequence, such as [1,2,3]. The score is calculated as (arr[i] + .... + arr[j])*len(i, j). Given a sequence and a value K, I needed to find the number of subsequences with a score not greater than K.
The coding question I received was:
Given a sequence of numbers, for example, [1, 2, 3], the score of a subsequence is (arr[i] + ... + arr[j]) * len(i, j). Given a sequence and a value K, find the number of subsequences with a score no greater than K.
For example, with the input [2, 1, 4, 3, 5] and K = 5, the subsequences that meet the criteria are [2], [1], [4], [3], and [5], so the result should be 5.
The required time complexity was O(n).