Longest Balanced Bitonic Subsequence
Updated
Problem statement
You are given an integer array nums. Choose a subsequence with one peak such that values are strictly increasing up to the peak and strictly decreasing after it.
The peak belongs to both sides. If each side contains k selected elements including the peak, the balanced bitonic subsequence has length 2 * k - 1.
Return the maximum possible length of a balanced bitonic subsequence.
Function
longestBalancedBitonicSubsequence(nums: int[]) → intExamples
Example 1
nums = [1,2,3,2,1,4,5,6,7,19,15,12,10,9]return = 9One balanced choice has five increasing elements ending at 19 and five decreasing elements starting there, for total length 2 * 5 - 1 = 9.
Example 2
nums = [1,2,3,2,1]return = 5The entire array is strictly increasing to 3 and then strictly decreasing, with three elements on each side including the peak.
Example 3
nums = [1,2,3,4]return = 1No element has a decreasing continuation, so only a single-element balanced subsequence is possible.
Example 4
nums = [1,3,2,4,3,2]return = 5Select 1, 3, 4, 3, 2. Both strict sides contain three elements including the peak.
Constraints
1 <= nums.length <= 2000.-10^9 <= nums[i] <= 10^9.
More Wells Fargo Online Assessment questions
- Server Upgrade PlanningOA · Seen Nov 2026
- Student and Course EnrollmentOA · Seen Nov 2026
- Bond Interest Summary Above 3%OA · Seen Oct 2026
- Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
- Event Statistics AggregatorOA · Seen Sep 2026
- Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
- Longest Subsequence That Is a SubstringOA · Seen Jul 2026
- Overloaded Game Account InventoriesOA · Seen Jul 2026
- Count Server ReplacementsOA · PHONE SCREEN · Seen Feb 2026
- Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026
Similar questions at other companies
- Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
- Maximum Beauty by DeletionsMeesho · OA
- Card Game: Best First-Player ScoreShopify · OAShopify interview questions
- 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 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