Questions Bank
Questions Bank
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:
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:
Input Format:
The input consists of a single line containing a string with characters (, ), {, }, [ and ].
Output Format:
Example:
Input:
()[]{}
Output:
True
Input:
(]
Output:
False
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:
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
Input Format:
Output Format:
Example:
Input:
123
Output:
24
Input:
45
Output:
18
Given a list of integers, find the maximum sum of any contiguous subarray.
Input Format:
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