Question: Question. Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i]
Question. Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j].
Input Format
First and only argument is an integer array A.
Output Format
Return an integer denoting the maximum value of j - i;
Example Input
Input 1:
A = [3, 5, 4, 2]
Example Output
Output 1:
2
Example Explanation
Explanation 1:
Maximum value occurs for pair (3, 4).
Python code and mcq explanation needed. Please don't copy from anywhere
1. Does Lambda contains return statements?
a) True
b) False
2. Which of the following is equivalent to random.randrange(3)?
a) range(3)
b) random.choice(range(0, 3))
c) random.shuffle(range(3))
d) random.select(range(3))
3. What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x)))))
a) ('[0] [1]',)
b) ('01',)
c) [0] [1]
d) 01
4. Which of the following is not a declaration of the dictionary?
a) {1: 'A', 2: 'B'}
b) dict([[1,"A"],[2,"B"]])
c) {1,"A",2"B"}
d) { }
5. What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
print(list(d.keys()))
a) ["john", "peter"]
b) ["john":40, "peter":45]
c) ("john", "peter")
d) ("john":40, "peter":45)
6. The error displayed in the following Python code is?
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))
a) 'list' object is not iterator
b) 'tuple' object is not iterator
c) 'list' object is iterator
d) 'tuple' object is iterator
7. What will be the output of the following Python code?
l=[-2, 4]
m=map(lambda x:x*2, l)
print(m)
a) [-4, 16]
b) Address of m
c) Error
d)
-4
16
8. Which of the following functions does not accept any arguments?
a) position
b) fillcolor
c) goto
d) setheading()
9. What is the value of x if x = math.ldexp(0.5, 1)?
a) 1
b) 2.0
c) 0.5
d) none of the mentioned
10. What will be the output shape of the following Python code?
import turtle
t=turtle.Pen()
for i in range(0,4):
t.forward(100)
t.left(120)
a) square
b) rectangle
c) triangle
d) kite
11. What will be the output of the following Python function (random module has already been imported)?
random.choice('sun')
a) sun
b) u
c) either s, u or n
d) error
12. What is the range of values that random.random() can return?
a) [0.0, 1.0]
b) (0.0, 1.0]
c) (0.0, 1.0)
d) [0.0, 1.0)
13. The following Python code snippet results in an error.
c=re.compile(r'(\d+)(\[A-Z]+)([a-z]+)')
c.groupindex
a) True
b) False
14. What will be the output of the following Python code snippet?
a = {}
a[1] = 1
a['1'] = 2
a[1]=a[1]+1
count = 0
for i in a:
count += a[i]
print(count)
a) 1
b) 2
c) 4
d) Error, the keys can't be a mixture of letters and numbers
15. The sleep function (under the time module) is used to ___________
a) Pause the code for the specified number of seconds
b) Return the specified number of seconds, in terms of milliseconds
c) Stop the execution of the code
d) Return the output of the code had it been executed earlier by the specified number of seconds
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
