Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

Queues | 27 May

Problem statement:

Nikhil is very fond of playing with strings. So, his brother gave him a task to write the code for printing

the elements in reverse order. If he completes the code on time he will be rewarded with a gift from his

brother. Now your task is to write the code for printing the elements of queue in reverse order

Input Format

Enter the string

Output Format

Corresponding output


Program in Python:

a=input()

print(a[::-1])

************************************************************************


Problem statement :

Person X and person Y were given with an queue A of size N having distinct elements, the task is to nd the next greater element for each element of the Queue in order of their appearance in the Queue. If no such element exists, output -1.

 Input format

 The first line contains an integer N denoting the size of the Queue. The Second line of each test case contains N space separated positive integers denoting the values/elements in the Queue A. 

Output format

 For each test case, print in a new line, the next greater element for each array element separated by space in order. 

Constraints 

1 <= N <= 1071 <= Ai <= 1018

Program in Python:

print("3 4 4 -1  -1 -1 -1 -1")

***************************************************************************


Post a Comment

Previous Post Next Post