Problem · Array
Match Subarray to Pattern
Learn this problemProblem statement
Note - Checkout the source image below for the original prompt :)
Imagine you're given a list of numbers and a special pattern that describes how these numbers should relate to each other in a sequence—whether they rise, fall, or stay the same. Your task is to find how many smaller sequences within the list match this pattern exactly. Even though you don't need to find the most efficient way, your solution should be good enough to handle a reasonable amount of work without slowing down too much.
Function
uberMathToPattern(numbers: int[], pattern: int[]) → intExamples
Example 1
numbers = [4, 1, 3, 4, 4, 5, 5, 1]pattern = [1, 0, -1]return = 1Note - Checkout the source image below for the original explanation :)
Constraints
🍅🍅More Uber problems
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026