Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python code for the following: Your task is to build an array of a specific size by values within the range from lowerbound to upperbound.

Python code for the following:

Your task is to build an array of a specific size by values within the range from lowerbound to upperbound. the array must be strictly increasing at first and then strictly decreasing. If several arrays could be constructed under those constraints, return the winning array with maximum elements starting from the lefthand side. For instance,[3,4,3,2] beats [2,3,4,3], since the first element is larger in the former array. [1,2,3,4,3] beats[1,2,3,2,1], since the fourth element is larger in the former array. If it is impossible to build such an array, return None/null.

Input

The input to the function/method has three arguments:

n, an integer representing the size of the result array; lowerbound an integer representing the lower bound of integer range. The values in result must be more than or equal to lowerbound; upperbound, an integer representing the upper bound of integer range in result. The values in result must be less than or equal to upperbound;

Output

Return a list of integers representing the maximum winning array and if the list is not possible then return None/null.

Constraints

3<=n<=10^6

1<=lowerbound<=upperbound<=10^6

Example

Input:

n=4

lowerbound = 10

upperbound = 12

output:

[11,12,11,10]

Explanation:

In this case, [11,12,11,10] is the winning array. It maintains the constraints of being first strictly increasing and then strictly decreasing, and any other valid arrays, such as [10,11,12,11] and [10,12,11,10] are less than [11,12,11,10]

So [11,12,11,10] is the maximum winning array.

Input:

n=6

lowerbound = 1

upperbound = 3

output:

null

Explanation:

Impossible to construct an array of size n strictly increasing at first and then strictly decreasing within the bounds.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions