0% found this document useful (0 votes)
11 views5 pages

Questions Bank

Uploaded by

anishsarawgi9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Questions Bank

Uploaded by

anishsarawgi9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Prime Numbers Between Second Largest and Second Smallest

Problem Statement:

Given a list of at least 3 integers, find and print all prime numbers between the second largest and
second smallest numbers (inclusive).

Input Format:

 The input consists of a single line containing space-separated integers.

Output Format:

 Print all the prime numbers between the second largest and second smallest numbers
(inclusive), each separated by a space.

 If there are no prime numbers in this range, print "No prime numbers".

Examples:

Input:

10 5 3 7 2

Output:

35

Input:

49187

Output:

No prime numbers
2. Valid Parentheses

Problem Statement:

Given a string containing just the characters (, ), {, }, [ and ], determine if the input string is valid.
An input string is valid if:

1. Open brackets must be closed by the same type of brackets.

Input Format:

 The input consists of a single line containing a string with characters (, ), {, }, [ and ].

Output Format:

 Print "True" if the input string is valid, otherwise print "False".

Example:

Input:

()[]{}

Output:

True

Input:

(]

Output:

False

3. Longest Increasing Subsequence in Binary


Problem Statement:

Given an array of integers in base 10, find the length of the longest increasing subsequence.
Convert this length to a binary number and print the binary representation.

Input Format:

 The input consists of a single line containing space-separated integers.

Output Format:

 Print a single line containing the binary representation of the length of the longest
increasing subsequence.

Example:

Input:

10 22 9 33 21 50 41 60 80

Output:

11

Input:

3 10 2 1 20

Output:

10

4. Sum of All Subsets


Problem Statement:

Given a list of integers, calculate the sum of all possible subsets.

Input Format:

 The input consists of a single line containing space-separated integers.

Output Format:

 Print a single integer, which is the sum of all subsets.

Example:

Input:

123

Output:

24

Input:

45

Output:

18

5. Maximum Subarray Sum


Problem Statement:

Given a list of integers, find the maximum sum of any contiguous subarray.

Input Format:

 The input consists of a single line containing space-separated integers.

Output Format:

 Print a single integer, which is the maximum sum of any contiguous subarray.

Examples:

Input:

-2 1 -3 4 -1 2 1 -5 4

Output:

Input:

1234

Output:

10

You might also like