FastPrepFind Length of Longest Bitonic Subarray
Problems/Find Length of Longest Bitonic Subarray

Find Length of Longest Bitonic Subarray

IBM logoIBM● MediumOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

A bitonic sequence is a sequence of numbers that first increase (non-decreasing) and then decreases (non-increasing). Given an array of integers, find the length of the longest subarray that is bitonic in nature.

Function

findLengthOfLongestBitonicSubarray(arr: int[]) → int

Examples

Example 1

arr = [10, 8, 9, 15, 12, 6, 7]return = 5

[8,9,15,12,6] is the longest bitonic subarray. Return its length, 5.

Example 2

arr = [5, 1, 2, 1, 4, 5]return = 3

[1,2,1] is the longest bitonic subarray. Note that the subarray [1,4,5] is also bitonic in nature and has the same length. It is non-decreasing through [1,4,5] and the non-increasing portion is [5].

Example 3

arr = [9, 7, 6, 2, 1]return = 5

The non-decreasing subarray is [9]. The non-increasing subarray is the entire array. The entire array has 5 elements.

Constraints

  • 1 <= arr.length <= 10^5
  • 0 <= arr[i] <= 10^9

More IBM interview questions

  • Missing IntervalsOA · Seen Nov 2026
  • Count Peaks and ValleysOA · Seen Nov 2026
  • Last Object Exit TimeOA · Seen Nov 2026
  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
  • Alternate Odd and Even Numbers with Two GoroutinesPHONE SCREEN · Seen Nov 2026
  • Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Nov 2026
  • Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
  • Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions
  • House RobberWalmart · OAWalmart interview questions

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int findLengthOfLongestBitonicSubarray(int[] arr) {
        // write your code here
    }
}
Checking account…