UBS Online Assessment Question/HARD DP Problem
Anonymous User
669

Given two arrays team_a and team_b of n integers each, choose two indices i and j such that the subarrays [team_a[i], team_a[i+1]... team_a[j]] and [team_b[i], team_b[i+1]... team_b[j]] can form a non decreasing sequence. Find the maximum possible value of (j-1+1) i.e. the length of the chosen subarray.
print(get_max_team([3,2,5,3], [10,2,8,4])) # Output: 2
print(get_max_team([2,7,3], [4,2,6])) # Output: 3
print(get_max_team([5,2,4,1], [2,6,2,2])) # Output: 3

Can someone please help me with this question. Got this in UBS online assessment and wasnt able to solve

Comments (3)